<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 6.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha256-CTSx/A06dm1B063156EVh15m6Y67pAjZZaQc89LLSrU=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.24/fancybox/fancybox.css" integrity="sha256-vQkngPS8jiHHH0I6ABTZroZk8NPZ7b+MUReOFE9UsXQ=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"rjyblog.gitee.io","root":"/","images":"/images","scheme":"Pisces","darkmode":false,"version":"8.18.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":null},"fold":{"enable":false,"height":500},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文基于Fresco 3.0.0，对Fresco源码进行了详细的解析。">
<meta property="og:type" content="article">
<meta property="og:title" content="Fresco源码详解">
<meta property="og:url" content="https://rjyblog.gitee.io/posts/863074da.html">
<meta property="og:site_name" content="任建勇的博客">
<meta property="og:description" content="本文基于Fresco 3.0.0，对Fresco源码进行了详细的解析。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-08-29T13:44:18.000Z">
<meta property="article:modified_time" content="2023-10-18T07:40:44.944Z">
<meta property="article:author" content="Jason">
<meta property="article:tag" content="Android">
<meta property="article:tag" content="Fresco">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="https://rjyblog.gitee.io/posts/863074da.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://rjyblog.gitee.io/posts/863074da.html","path":"posts/863074da.html","title":"Fresco源码详解"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>Fresco源码详解 | 任建勇的博客</title>
  








  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">任建勇的博客</p>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%9B%BE%E7%89%87%E5%8A%A0%E8%BD%BD%E8%BF%87%E7%A8%8B"><span class="nav-text">图片加载过程</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#PipelineDraweeController%E7%9A%84%E6%9E%84%E9%80%A0%E8%BF%87%E7%A8%8B"><span class="nav-text">PipelineDraweeController的构造过程</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%89%E7%BA%A7%E7%BC%93%E5%AD%98%E6%9C%BA%E5%88%B6"><span class="nav-text">三级缓存机制</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%86%85%E5%AD%98%E7%BC%93%E5%AD%98%E6%B1%A0"><span class="nav-text">内存缓存池</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%86%85%E5%AD%98%E5%9D%97%E7%BC%93%E5%AD%98%E6%B1%A0-MemoryChunkPool"><span class="nav-text">内存块缓存池-MemoryChunkPool</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AD%97%E8%8A%82%E5%86%85%E5%AD%98%E7%BC%93%E5%AD%98%E6%B1%A0-ByteArrayPool"><span class="nav-text">字节内存缓存池 ByteArrayPool</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%9B%BE%E7%89%87%E8%A7%A3%E7%A0%81%E5%99%A8"><span class="nav-text">图片解码器</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Bitmap%E5%86%85%E5%AD%98%E5%8D%A0%E7%94%A8"><span class="nav-text">Bitmap内存占用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Bitmap%E5%A4%8D%E7%94%A8"><span class="nav-text">Bitmap复用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%A7%A3%E7%A0%81%E7%9A%84%E4%B8%B4%E6%97%B6%E7%BC%93%E5%AD%98"><span class="nav-text">解码的临时缓存</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%9B%BE%E7%89%87%E5%A4%84%E7%90%86%E7%94%9F%E4%BA%A7%E8%80%85%E5%BA%8F%E5%88%97"><span class="nav-text">图片处理生产者序列</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#NetworkFetchProducer"><span class="nav-text">NetworkFetchProducer</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#DiskCacheWriteProducer"><span class="nav-text">DiskCacheWriteProducer</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#DiskCacheReadProducer"><span class="nav-text">DiskCacheReadProducer</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#EncodedMemoryCacheProducer"><span class="nav-text">EncodedMemoryCacheProducer</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#DecodeProducer"><span class="nav-text">DecodeProducer</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#BitmapMemoryCacheProducer"><span class="nav-text">BitmapMemoryCacheProducer</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%BB%8E%E7%BC%93%E5%AD%98%E8%8E%B7%E5%8F%96Bitmap"><span class="nav-text">从缓存获取Bitmap</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#BitmapPrepareProducer"><span class="nav-text">BitmapPrepareProducer</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99"><span class="nav-text">参考资料</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Jason"
      src="/images/avatar.png">
  <p class="site-author-name" itemprop="name">Jason</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">66</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">13</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">23</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://rjyblog.gitee.io/posts/863074da.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="Jason">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="任建勇的博客">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="Fresco源码详解 | 任建勇的博客">
      <meta itemprop="description" content="本文基于Fresco 3.0.0，对Fresco源码进行了详细的解析。">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Fresco源码详解
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-08-29 21:44:18" itemprop="dateCreated datePublished" datetime="2023-08-29T21:44:18+08:00">2023-08-29</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">更新于</span>
      <time title="修改时间：2023-10-18 15:40:44" itemprop="dateModified" datetime="2023-10-18T15:40:44+08:00">2023-10-18</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Android/" itemprop="url" rel="index"><span itemprop="name">Android</span></a>
        </span>
    </span>

  
</div>

            <div class="post-description">本文基于Fresco 3.0.0，对Fresco源码进行了详细的解析。</div>
        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><!-- 
`com.facebook.imagepipeline.image.EncodedImage#getInputStream`是什么？
`com.facebook.imagepipeline.platform.DefaultDecoder#decodeFromStream`会首先通过`mDecodeBuffers.acquire()`获取byteBuffer，如果获取不到就通过`ByteBuffer.allocate`来申请内存。 
-->

<p>通过Fresco加载图片，最简单的方式是通过<code>SimpleDraweeView</code>来展示图片，示例代码如下：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">com.facebook.drawee.view.SimpleDraweeView</span></span></span><br><span class="line"><span class="tag">    <span class="attr">android:id</span>=<span class="string">&quot;@+id/my_image_view&quot;</span></span></span><br><span class="line"><span class="tag">    <span class="attr">android:layout_width</span>=<span class="string">&quot;130dp&quot;</span></span></span><br><span class="line"><span class="tag">    <span class="attr">android:layout_height</span>=<span class="string">&quot;130dp&quot;</span></span></span><br><span class="line"><span class="tag">    <span class="attr">fresco:placeholderImage</span>=<span class="string">&quot;@drawable/my_drawable&quot;</span></span></span><br><span class="line"><span class="tag">  /&gt;</span></span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//示例代码在Fragment#onViewCreated中调用</span></span><br><span class="line"><span class="type">Uri</span> <span class="variable">uri</span> <span class="operator">=</span> Uri.parse(<span class="string">&quot;https://frescolib.org/static/sample-images/animal_a.png&quot;</span>);</span><br><span class="line"><span class="type">SimpleDraweeView</span> <span class="variable">draweeView</span> <span class="operator">=</span> (SimpleDraweeView) findViewById(R.id.my_image_view);</span><br><span class="line">draweeView.setImageURI(uri);</span><br></pre></td></tr></table></figure>

<p>先看一下<code>SimpleDraweeView</code>相关的类图结构：</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="510px" preserveAspectRatio="none" style="width:903px;height:510px;background:#FFFFFF;" version="1.1" viewBox="0 0 903 510" width="903px" zoomAndPan="magnify"><defs/><g><!--class ImageView--><g id="elem_ImageView"><rect fill="#F1F1F1" height="48" id="ImageView" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="110" x="88.5" y="7"/><ellipse cx="103.5" cy="23" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M105.8438,18.6719 C104.9063,18.2344 104.3125,18.0938 103.4375,18.0938 C100.8125,18.0938 98.8125,20.1719 98.8125,22.8906 L98.8125,24.0156 C98.8125,26.5938 100.9219,28.4844 103.8125,28.4844 C105.0313,28.4844 106.1875,28.1875 106.9375,27.6406 C107.5156,27.2344 107.8438,26.7813 107.8438,26.3906 C107.8438,25.9375 107.4531,25.5469 106.9844,25.5469 C106.7656,25.5469 106.5625,25.625 106.375,25.8125 C105.9219,26.2969 105.9219,26.2969 105.7344,26.3906 C105.3125,26.6563 104.625,26.7813 103.8594,26.7813 C101.8125,26.7813 100.5156,25.6875 100.5156,23.9844 L100.5156,22.8906 C100.5156,21.1094 101.7656,19.7969 103.5,19.7969 C104.0781,19.7969 104.6875,19.9531 105.1563,20.2031 C105.6406,20.4844 105.8125,20.7031 105.9063,21.1094 C105.9688,21.5156 106,21.6406 106.1406,21.7656 C106.2813,21.9063 106.5156,22.0156 106.7344,22.0156 C107,22.0156 107.2656,21.875 107.4375,21.6563 C107.5469,21.5 107.5781,21.3125 107.5781,20.8906 L107.5781,19.4688 C107.5781,19.0313 107.5625,18.9063 107.4688,18.75 C107.3125,18.4844 107.0313,18.3438 106.7344,18.3438 C106.4375,18.3438 106.2344,18.4375 106.0156,18.75 L105.8438,18.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="78" x="117.5" y="27.8467">ImageView</text><line style="stroke:#181818;stroke-width:0.5;" x1="89.5" x2="197.5" y1="39" y2="39"/><line style="stroke:#181818;stroke-width:0.5;" x1="89.5" x2="197.5" y1="47" y2="47"/></g><!--class DraweeView--><g id="elem_DraweeView"><rect codeLine="3" fill="#F1F1F1" height="48" id="DraweeView" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="273" x="7" y="123"/><ellipse cx="22" cy="139" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M24.3438,134.6719 C23.4063,134.2344 22.8125,134.0938 21.9375,134.0938 C19.3125,134.0938 17.3125,136.1719 17.3125,138.8906 L17.3125,140.0156 C17.3125,142.5938 19.4219,144.4844 22.3125,144.4844 C23.5313,144.4844 24.6875,144.1875 25.4375,143.6406 C26.0156,143.2344 26.3438,142.7813 26.3438,142.3906 C26.3438,141.9375 25.9531,141.5469 25.4844,141.5469 C25.2656,141.5469 25.0625,141.625 24.875,141.8125 C24.4219,142.2969 24.4219,142.2969 24.2344,142.3906 C23.8125,142.6563 23.125,142.7813 22.3594,142.7813 C20.3125,142.7813 19.0156,141.6875 19.0156,139.9844 L19.0156,138.8906 C19.0156,137.1094 20.2656,135.7969 22,135.7969 C22.5781,135.7969 23.1875,135.9531 23.6563,136.2031 C24.1406,136.4844 24.3125,136.7031 24.4063,137.1094 C24.4688,137.5156 24.5,137.6406 24.6406,137.7656 C24.7813,137.9063 25.0156,138.0156 25.2344,138.0156 C25.5,138.0156 25.7656,137.875 25.9375,137.6563 C26.0469,137.5 26.0781,137.3125 26.0781,136.8906 L26.0781,135.4688 C26.0781,135.0313 26.0625,134.9063 25.9688,134.75 C25.8125,134.4844 25.5313,134.3438 25.2344,134.3438 C24.9375,134.3438 24.7344,134.4375 24.5156,134.75 L24.3438,134.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="88" x="36" y="143.8467">DraweeView</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="151" x="132" y="120"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="149" x="133" y="132.1387">GenericDraweeHierarchy</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="279" y1="155" y2="155"/><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="279" y1="163" y2="163"/></g><!--class GenericDraweeView--><g id="elem_GenericDraweeView"><rect fill="#F1F1F1" height="48" id="GenericDraweeView" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="176" x="79.5" y="239"/><ellipse cx="94.5" cy="255" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M96.8438,250.6719 C95.9063,250.2344 95.3125,250.0938 94.4375,250.0938 C91.8125,250.0938 89.8125,252.1719 89.8125,254.8906 L89.8125,256.0156 C89.8125,258.5938 91.9219,260.4844 94.8125,260.4844 C96.0313,260.4844 97.1875,260.1875 97.9375,259.6406 C98.5156,259.2344 98.8438,258.7813 98.8438,258.3906 C98.8438,257.9375 98.4531,257.5469 97.9844,257.5469 C97.7656,257.5469 97.5625,257.625 97.375,257.8125 C96.9219,258.2969 96.9219,258.2969 96.7344,258.3906 C96.3125,258.6563 95.625,258.7813 94.8594,258.7813 C92.8125,258.7813 91.5156,257.6875 91.5156,255.9844 L91.5156,254.8906 C91.5156,253.1094 92.7656,251.7969 94.5,251.7969 C95.0781,251.7969 95.6875,251.9531 96.1563,252.2031 C96.6406,252.4844 96.8125,252.7031 96.9063,253.1094 C96.9688,253.5156 97,253.6406 97.1406,253.7656 C97.2813,253.9063 97.5156,254.0156 97.7344,254.0156 C98,254.0156 98.2656,253.875 98.4375,253.6563 C98.5469,253.5 98.5781,253.3125 98.5781,252.8906 L98.5781,251.4688 C98.5781,251.0313 98.5625,250.9063 98.4688,250.75 C98.3125,250.4844 98.0313,250.3438 97.7344,250.3438 C97.4375,250.3438 97.2344,250.4375 97.0156,250.75 L96.8438,250.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="144" x="108.5" y="259.8467">GenericDraweeView</text><line style="stroke:#181818;stroke-width:0.5;" x1="80.5" x2="254.5" y1="271" y2="271"/><line style="stroke:#181818;stroke-width:0.5;" x1="80.5" x2="254.5" y1="279" y2="279"/></g><!--class SimpleDraweeView--><g id="elem_SimpleDraweeView"><rect codeLine="5" fill="#ADD8E6" height="48" id="SimpleDraweeView" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="170" x="96.5" y="347"/><ellipse cx="111.5" cy="363" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M113.8438,358.6719 C112.9063,358.2344 112.3125,358.0938 111.4375,358.0938 C108.8125,358.0938 106.8125,360.1719 106.8125,362.8906 L106.8125,364.0156 C106.8125,366.5938 108.9219,368.4844 111.8125,368.4844 C113.0313,368.4844 114.1875,368.1875 114.9375,367.6406 C115.5156,367.2344 115.8438,366.7813 115.8438,366.3906 C115.8438,365.9375 115.4531,365.5469 114.9844,365.5469 C114.7656,365.5469 114.5625,365.625 114.375,365.8125 C113.9219,366.2969 113.9219,366.2969 113.7344,366.3906 C113.3125,366.6563 112.625,366.7813 111.8594,366.7813 C109.8125,366.7813 108.5156,365.6875 108.5156,363.9844 L108.5156,362.8906 C108.5156,361.1094 109.7656,359.7969 111.5,359.7969 C112.0781,359.7969 112.6875,359.9531 113.1563,360.2031 C113.6406,360.4844 113.8125,360.7031 113.9063,361.1094 C113.9688,361.5156 114,361.6406 114.1406,361.7656 C114.2813,361.9063 114.5156,362.0156 114.7344,362.0156 C115,362.0156 115.2656,361.875 115.4375,361.6563 C115.5469,361.5 115.5781,361.3125 115.5781,360.8906 L115.5781,359.4688 C115.5781,359.0313 115.5625,358.9063 115.4688,358.75 C115.3125,358.4844 115.0313,358.3438 114.7344,358.3438 C114.4375,358.3438 114.2344,358.4375 114.0156,358.75 L113.8438,358.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="138" x="125.5" y="367.8467">SimpleDraweeView</text><line style="stroke:#181818;stroke-width:0.5;" x1="97.5" x2="265.5" y1="379" y2="379"/><line style="stroke:#181818;stroke-width:0.5;" x1="97.5" x2="265.5" y1="387" y2="387"/></g><!--class DraweeHierarchy--><g id="elem_DraweeHierarchy"><rect codeLine="10" fill="#F1F1F1" height="64.2969" id="DraweeHierarchy" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="260" x="636.5" y="115"/><ellipse cx="699.75" cy="131" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M700.7031,127.7813 L702.4219,127.7813 C702.8125,127.7813 703,127.75 703.125,127.6719 C703.3906,127.5156 703.5313,127.2344 703.5313,126.9375 C703.5313,126.6719 703.4219,126.4063 703.1875,126.2344 C703.0156,126.125 702.875,126.0938 702.4219,126.0938 L697.2813,126.0938 C696.8438,126.0938 696.7188,126.1094 696.5625,126.2031 C696.3125,126.3594 696.1563,126.6563 696.1563,126.9375 C696.1563,127.2188 696.2969,127.4688 696.5156,127.6406 C696.6719,127.75 696.8594,127.7813 697.2813,127.7813 L699,127.7813 L699,134.2969 L697.2813,134.2969 C696.8438,134.2969 696.7188,134.3125 696.5625,134.4219 C696.3125,134.5781 696.1563,134.8594 696.1563,135.1563 C696.1563,135.4063 696.2969,135.6719 696.5156,135.8281 C696.6719,135.9531 696.875,136 697.2813,136 L702.4219,136 C703.1719,136 703.5313,135.7188 703.5313,135.1563 C703.5313,134.875 703.4219,134.625 703.1875,134.4531 C703.0156,134.3281 702.875,134.2969 702.4219,134.2969 L700.7031,134.2969 L700.7031,127.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="125" x="720.25" y="135.8467">DraweeHierarchy</text><line style="stroke:#181818;stroke-width:0.5;" x1="637.5" x2="895.5" y1="147" y2="147"/><line style="stroke:#181818;stroke-width:0.5;" x1="637.5" x2="895.5" y1="155" y2="155"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="248" x="642.5" y="171.9951">getTopLevelDrawable() : Drawable</text></g><!--class SettableDraweeHierarchy--><g id="elem_SettableDraweeHierarchy"><rect codeLine="13" fill="#F1F1F1" height="48" id="SettableDraweeHierarchy" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="216" x="658.5" y="239"/><ellipse cx="673.5" cy="255" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M674.4531,251.7813 L676.1719,251.7813 C676.5625,251.7813 676.75,251.75 676.875,251.6719 C677.1406,251.5156 677.2813,251.2344 677.2813,250.9375 C677.2813,250.6719 677.1719,250.4063 676.9375,250.2344 C676.7656,250.125 676.625,250.0938 676.1719,250.0938 L671.0313,250.0938 C670.5938,250.0938 670.4688,250.1094 670.3125,250.2031 C670.0625,250.3594 669.9063,250.6563 669.9063,250.9375 C669.9063,251.2188 670.0469,251.4688 670.2656,251.6406 C670.4219,251.75 670.6094,251.7813 671.0313,251.7813 L672.75,251.7813 L672.75,258.2969 L671.0313,258.2969 C670.5938,258.2969 670.4688,258.3125 670.3125,258.4219 C670.0625,258.5781 669.9063,258.8594 669.9063,259.1563 C669.9063,259.4063 670.0469,259.6719 670.2656,259.8281 C670.4219,259.9531 670.625,260 671.0313,260 L676.1719,260 C676.9219,260 677.2813,259.7188 677.2813,259.1563 C677.2813,258.875 677.1719,258.625 676.9375,258.4531 C676.7656,258.3281 676.625,258.2969 676.1719,258.2969 L674.4531,258.2969 L674.4531,251.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="184" x="687.5" y="259.8467">SettableDraweeHierarchy</text><line style="stroke:#181818;stroke-width:0.5;" x1="659.5" x2="873.5" y1="271" y2="271"/><line style="stroke:#181818;stroke-width:0.5;" x1="659.5" x2="873.5" y1="279" y2="279"/></g><!--class GenericDraweeHierarchy--><g id="elem_GenericDraweeHierarchy"><rect codeLine="14" fill="#F1F1F1" height="48" id="GenericDraweeHierarchy" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="210" x="661.5" y="347"/><ellipse cx="676.5" cy="363" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M678.8438,358.6719 C677.9063,358.2344 677.3125,358.0938 676.4375,358.0938 C673.8125,358.0938 671.8125,360.1719 671.8125,362.8906 L671.8125,364.0156 C671.8125,366.5938 673.9219,368.4844 676.8125,368.4844 C678.0313,368.4844 679.1875,368.1875 679.9375,367.6406 C680.5156,367.2344 680.8438,366.7813 680.8438,366.3906 C680.8438,365.9375 680.4531,365.5469 679.9844,365.5469 C679.7656,365.5469 679.5625,365.625 679.375,365.8125 C678.9219,366.2969 678.9219,366.2969 678.7344,366.3906 C678.3125,366.6563 677.625,366.7813 676.8594,366.7813 C674.8125,366.7813 673.5156,365.6875 673.5156,363.9844 L673.5156,362.8906 C673.5156,361.1094 674.7656,359.7969 676.5,359.7969 C677.0781,359.7969 677.6875,359.9531 678.1563,360.2031 C678.6406,360.4844 678.8125,360.7031 678.9063,361.1094 C678.9688,361.5156 679,361.6406 679.1406,361.7656 C679.2813,361.9063 679.5156,362.0156 679.7344,362.0156 C680,362.0156 680.2656,361.875 680.4375,361.6563 C680.5469,361.5 680.5781,361.3125 680.5781,360.8906 L680.5781,359.4688 C680.5781,359.0313 680.5625,358.9063 680.4688,358.75 C680.3125,358.4844 680.0313,358.3438 679.7344,358.3438 C679.4375,358.3438 679.2344,358.4375 679.0156,358.75 L678.8438,358.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="178" x="690.5" y="367.8467">GenericDraweeHierarchy</text><line style="stroke:#181818;stroke-width:0.5;" x1="662.5" x2="870.5" y1="379" y2="379"/><line style="stroke:#181818;stroke-width:0.5;" x1="662.5" x2="870.5" y1="387" y2="387"/></g><!--class DraweeController--><g id="elem_DraweeController"><rect codeLine="18" fill="#F1F1F1" height="48" id="DraweeController" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="158" x="353.5" y="239"/><ellipse cx="368.5" cy="255" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M369.4531,251.7813 L371.1719,251.7813 C371.5625,251.7813 371.75,251.75 371.875,251.6719 C372.1406,251.5156 372.2813,251.2344 372.2813,250.9375 C372.2813,250.6719 372.1719,250.4063 371.9375,250.2344 C371.7656,250.125 371.625,250.0938 371.1719,250.0938 L366.0313,250.0938 C365.5938,250.0938 365.4688,250.1094 365.3125,250.2031 C365.0625,250.3594 364.9063,250.6563 364.9063,250.9375 C364.9063,251.2188 365.0469,251.4688 365.2656,251.6406 C365.4219,251.75 365.6094,251.7813 366.0313,251.7813 L367.75,251.7813 L367.75,258.2969 L366.0313,258.2969 C365.5938,258.2969 365.4688,258.3125 365.3125,258.4219 C365.0625,258.5781 364.9063,258.8594 364.9063,259.1563 C364.9063,259.4063 365.0469,259.6719 365.2656,259.8281 C365.4219,259.9531 365.625,260 366.0313,260 L371.1719,260 C371.9219,260 372.2813,259.7188 372.2813,259.1563 C372.2813,258.875 372.1719,258.625 371.9375,258.4531 C371.7656,258.3281 371.625,258.2969 371.1719,258.2969 L369.4531,258.2969 L369.4531,251.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="126" x="382.5" y="259.8467">DraweeController</text><line style="stroke:#181818;stroke-width:0.5;" x1="354.5" x2="510.5" y1="271" y2="271"/><line style="stroke:#181818;stroke-width:0.5;" x1="354.5" x2="510.5" y1="279" y2="279"/></g><!--class DraweeHolder--><g id="elem_DraweeHolder"><rect codeLine="21" fill="#F1F1F1" height="48" id="DraweeHolder" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="286" x="315.5" y="123"/><ellipse cx="330.5" cy="139" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M332.8438,134.6719 C331.9063,134.2344 331.3125,134.0938 330.4375,134.0938 C327.8125,134.0938 325.8125,136.1719 325.8125,138.8906 L325.8125,140.0156 C325.8125,142.5938 327.9219,144.4844 330.8125,144.4844 C332.0313,144.4844 333.1875,144.1875 333.9375,143.6406 C334.5156,143.2344 334.8438,142.7813 334.8438,142.3906 C334.8438,141.9375 334.4531,141.5469 333.9844,141.5469 C333.7656,141.5469 333.5625,141.625 333.375,141.8125 C332.9219,142.2969 332.9219,142.2969 332.7344,142.3906 C332.3125,142.6563 331.625,142.7813 330.8594,142.7813 C328.8125,142.7813 327.5156,141.6875 327.5156,139.9844 L327.5156,138.8906 C327.5156,137.1094 328.7656,135.7969 330.5,135.7969 C331.0781,135.7969 331.6875,135.9531 332.1563,136.2031 C332.6406,136.4844 332.8125,136.7031 332.9063,137.1094 C332.9688,137.5156 333,137.6406 333.1406,137.7656 C333.2813,137.9063 333.5156,138.0156 333.7344,138.0156 C334,138.0156 334.2656,137.875 334.4375,137.6563 C334.5469,137.5 334.5781,137.3125 334.5781,136.8906 L334.5781,135.4688 C334.5781,135.0313 334.5625,134.9063 334.4688,134.75 C334.3125,134.4844 334.0313,134.3438 333.7344,134.3438 C333.4375,134.3438 333.2344,134.4375 333.0156,134.75 L332.8438,134.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="101" x="344.5" y="143.8467">DraweeHolder</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="151" x="453.5" y="120"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="149" x="454.5" y="132.1387">GenericDraweeHierarchy</text><line style="stroke:#181818;stroke-width:0.5;" x1="316.5" x2="600.5" y1="155" y2="155"/><line style="stroke:#181818;stroke-width:0.5;" x1="316.5" x2="600.5" y1="163" y2="163"/></g><!--class VisibilityCallback--><g id="elem_VisibilityCallback"><rect codeLine="25" fill="#F1F1F1" height="48" id="VisibilityCallback" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="152" x="382.5" y="7"/><ellipse cx="397.5" cy="23" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M398.4531,19.7813 L400.1719,19.7813 C400.5625,19.7813 400.75,19.75 400.875,19.6719 C401.1406,19.5156 401.2813,19.2344 401.2813,18.9375 C401.2813,18.6719 401.1719,18.4063 400.9375,18.2344 C400.7656,18.125 400.625,18.0938 400.1719,18.0938 L395.0313,18.0938 C394.5938,18.0938 394.4688,18.1094 394.3125,18.2031 C394.0625,18.3594 393.9063,18.6563 393.9063,18.9375 C393.9063,19.2188 394.0469,19.4688 394.2656,19.6406 C394.4219,19.75 394.6094,19.7813 395.0313,19.7813 L396.75,19.7813 L396.75,26.2969 L395.0313,26.2969 C394.5938,26.2969 394.4688,26.3125 394.3125,26.4219 C394.0625,26.5781 393.9063,26.8594 393.9063,27.1563 C393.9063,27.4063 394.0469,27.6719 394.2656,27.8281 C394.4219,27.9531 394.625,28 395.0313,28 L400.1719,28 C400.9219,28 401.2813,27.7188 401.2813,27.1563 C401.2813,26.875 401.1719,26.625 400.9375,26.4531 C400.7656,26.3281 400.625,26.2969 400.1719,26.2969 L398.4531,26.2969 L398.4531,19.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="120" x="411.5" y="27.8467">VisibilityCallback</text><line style="stroke:#181818;stroke-width:0.5;" x1="383.5" x2="533.5" y1="39" y2="39"/><line style="stroke:#181818;stroke-width:0.5;" x1="383.5" x2="533.5" y1="47" y2="47"/></g><!--class RootDrawable--><g id="elem_RootDrawable"><rect fill="#F1F1F1" height="48" id="RootDrawable" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="134" x="699.5" y="455"/><ellipse cx="714.5" cy="471" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M716.8438,466.6719 C715.9063,466.2344 715.3125,466.0938 714.4375,466.0938 C711.8125,466.0938 709.8125,468.1719 709.8125,470.8906 L709.8125,472.0156 C709.8125,474.5938 711.9219,476.4844 714.8125,476.4844 C716.0313,476.4844 717.1875,476.1875 717.9375,475.6406 C718.5156,475.2344 718.8438,474.7813 718.8438,474.3906 C718.8438,473.9375 718.4531,473.5469 717.9844,473.5469 C717.7656,473.5469 717.5625,473.625 717.375,473.8125 C716.9219,474.2969 716.9219,474.2969 716.7344,474.3906 C716.3125,474.6563 715.625,474.7813 714.8594,474.7813 C712.8125,474.7813 711.5156,473.6875 711.5156,471.9844 L711.5156,470.8906 C711.5156,469.1094 712.7656,467.7969 714.5,467.7969 C715.0781,467.7969 715.6875,467.9531 716.1563,468.2031 C716.6406,468.4844 716.8125,468.7031 716.9063,469.1094 C716.9688,469.5156 717,469.6406 717.1406,469.7656 C717.2813,469.9063 717.5156,470.0156 717.7344,470.0156 C718,470.0156 718.2656,469.875 718.4375,469.6563 C718.5469,469.5 718.5781,469.3125 718.5781,468.8906 L718.5781,467.4688 C718.5781,467.0313 718.5625,466.9063 718.4688,466.75 C718.3125,466.4844 718.0313,466.3438 717.7344,466.3438 C717.4375,466.3438 717.2344,466.4375 717.0156,466.75 L716.8438,466.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="102" x="728.5" y="475.8467">RootDrawable</text><line style="stroke:#181818;stroke-width:0.5;" x1="700.5" x2="832.5" y1="487" y2="487"/><line style="stroke:#181818;stroke-width:0.5;" x1="700.5" x2="832.5" y1="495" y2="495"/></g><!--class AbstractDraweeController--><g id="elem_AbstractDraweeController"><rect codeLine="32" fill="#F1F1F1" height="48" id="AbstractDraweeController" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="217" x="324" y="347"/><ellipse cx="339" cy="363" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M341.0781,364.8125 L341.4688,365.7969 L341.0781,365.7969 C340.625,365.7969 340.5156,365.8125 340.3594,365.9219 C340.1094,366.0781 339.9531,366.3594 339.9531,366.6563 C339.9531,366.9219 340.0938,367.1719 340.3125,367.3281 C340.4531,367.4531 340.6563,367.5 341.0781,367.5 L343.4375,367.5 C343.7969,367.5 344.0156,367.4688 344.1563,367.375 C344.4063,367.2344 344.5625,366.9375 344.5625,366.6563 C344.5625,366.375 344.4219,366.125 344.2031,365.9688 C344.0313,365.8281 343.875,365.7969 343.4063,365.7969 L340.0156,357.5938 L336.3438,357.5938 C335.8906,357.5938 335.7656,357.6094 335.6094,357.7031 C335.3594,357.875 335.2031,358.1563 335.2031,358.4375 C335.2031,358.7188 335.3438,358.9688 335.5625,359.1406 C335.7344,359.25 335.9063,359.2813 336.3438,359.2813 L337.4219,359.2813 L334.7813,365.7969 C334.3594,365.7969 334.2031,365.8125 334.0469,365.9219 C333.7969,366.0781 333.6406,366.3594 333.6406,366.6563 C333.6406,367.2188 334.0156,367.5 334.7656,367.5 L337.0313,367.5 C337.3906,367.5 337.6094,367.4688 337.7344,367.375 C338,367.2344 338.1406,366.9375 338.1406,366.6563 C338.1406,366.375 338.0156,366.125 337.7969,365.9531 C337.625,365.8281 337.4844,365.7969 337.0313,365.7969 L336.6406,365.7969 L337.0313,364.8125 L341.0781,364.8125 Z M340.375,363.1094 L337.7031,363.1094 L339.0469,359.8438 L340.375,363.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="185" x="353" y="367.8467">AbstractDraweeController</text><line style="stroke:#181818;stroke-width:0.5;" x1="325" x2="540" y1="379" y2="379"/><line style="stroke:#181818;stroke-width:0.5;" x1="325" x2="540" y1="387" y2="387"/></g><!--class PipelineDraweeController--><g id="elem_PipelineDraweeController"><rect fill="#F1F1F1" height="48" id="PipelineDraweeController" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="217" x="324" y="455"/><ellipse cx="339" cy="471" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M341.3438,466.6719 C340.4063,466.2344 339.8125,466.0938 338.9375,466.0938 C336.3125,466.0938 334.3125,468.1719 334.3125,470.8906 L334.3125,472.0156 C334.3125,474.5938 336.4219,476.4844 339.3125,476.4844 C340.5313,476.4844 341.6875,476.1875 342.4375,475.6406 C343.0156,475.2344 343.3438,474.7813 343.3438,474.3906 C343.3438,473.9375 342.9531,473.5469 342.4844,473.5469 C342.2656,473.5469 342.0625,473.625 341.875,473.8125 C341.4219,474.2969 341.4219,474.2969 341.2344,474.3906 C340.8125,474.6563 340.125,474.7813 339.3594,474.7813 C337.3125,474.7813 336.0156,473.6875 336.0156,471.9844 L336.0156,470.8906 C336.0156,469.1094 337.2656,467.7969 339,467.7969 C339.5781,467.7969 340.1875,467.9531 340.6563,468.2031 C341.1406,468.4844 341.3125,468.7031 341.4063,469.1094 C341.4688,469.5156 341.5,469.6406 341.6406,469.7656 C341.7813,469.9063 342.0156,470.0156 342.2344,470.0156 C342.5,470.0156 342.7656,469.875 342.9375,469.6563 C343.0469,469.5 343.0781,469.3125 343.0781,468.8906 L343.0781,467.4688 C343.0781,467.0313 343.0625,466.9063 342.9688,466.75 C342.8125,466.4844 342.5313,466.3438 342.2344,466.3438 C341.9375,466.3438 341.7344,466.4375 341.5156,466.75 L341.3438,466.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="185" x="353" y="475.8467">PipelineDraweeController</text><line style="stroke:#181818;stroke-width:0.5;" x1="325" x2="540" y1="487" y2="487"/><line style="stroke:#181818;stroke-width:0.5;" x1="325" x2="540" y1="495" y2="495"/></g><!--reverse link ImageView to DraweeView--><g id="link_ImageView_DraweeView"><path codeLine="2" d="M143.5,73.07 C143.5,92.848 143.5,103.196 143.5,122.965 " fill="none" id="ImageView-backto-DraweeView" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="143.5,55.07,137.5,73.07,149.5,73.07,143.5,55.07" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DraweeView to GenericDraweeView--><g id="link_DraweeView_GenericDraweeView"><path codeLine="4" d="M152.0654,188.6839 C156.2294,208.4619 158.489,219.196 162.65,238.965 " fill="none" id="DraweeView-backto-GenericDraweeView" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="148.357,171.07,146.1941,189.92,157.9367,187.4477,148.357,171.07" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link GenericDraweeView to SimpleDraweeView--><g id="link_GenericDraweeView_SimpleDraweeView"><path codeLine="6" d="M172.8947,304.8451 C175.2267,322.5031 176.077,328.941 178.42,346.678 " fill="none" id="GenericDraweeView-backto-SimpleDraweeView" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="170.538,287,166.9464,305.6306,178.8431,304.0595,170.538,287" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link SettableDraweeHierarchy to GenericDraweeHierarchy--><g id="link_SettableDraweeHierarchy_GenericDraweeHierarchy"><path codeLine="15" d="M766.5,305 C766.5,322.658 766.5,328.941 766.5,346.678 " fill="none" id="SettableDraweeHierarchy-backto-GenericDraweeHierarchy" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="766.5,287,760.5,305,772.5,305,766.5,287" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DraweeHierarchy to SettableDraweeHierarchy--><g id="link_DraweeHierarchy_SettableDraweeHierarchy"><path codeLine="19" d="M766.5,197.151 C766.5,216.005 766.5,221.647 766.5,238.845 " fill="none" id="DraweeHierarchy-backto-SettableDraweeHierarchy" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="766.5,179.151,760.5,197.151,772.5,197.151,766.5,179.151" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DraweeHolder to DraweeController--><g id="link_DraweeHolder_DraweeController"><path codeLine="22" d="M450.5705,182.7695 C446.0595,202.5475 442.262,219.196 437.754,238.965 " fill="none" id="DraweeHolder-backto-DraweeController" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="453.239,171.07,448.0049,176.0303,450.5705,182.7695,455.8046,177.8093,453.239,171.07" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DraweeHolder to DraweeHierarchy--><g id="link_DraweeHolder_DraweeHierarchy"><path codeLine="23" d="M613.672,147 C625.261,147 624.851,147 636.44,147 " fill="none" id="DraweeHolder-backto-DraweeHierarchy" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="601.672,147,607.672,151,613.672,147,607.672,143,601.672,147" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link VisibilityCallback to DraweeHolder--><g id="link_VisibilityCallback_DraweeHolder"><path codeLine="26" d="M458.5,73.07 C458.5,92.848 458.5,103.196 458.5,122.965 " fill="none" id="VisibilityCallback-backto-DraweeHolder" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="458.5,55.07,452.5,73.07,464.5,73.07,458.5,55.07" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DraweeView to DraweeHolder--><g id="link_DraweeView_DraweeHolder"><path codeLine="27" d="M292.082,147 C303.814,147 303.546,147 315.278,147 " fill="none" id="DraweeView-backto-DraweeHolder" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="280.082,147,286.082,151,292.082,147,286.082,143,280.082,147" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link GenericDraweeHierarchy to RootDrawable--><g id="link_GenericDraweeHierarchy_RootDrawable"><path codeLine="29" d="M766.5,407 C766.5,424.6584 766.5,436.9408 766.5,454.6784 " fill="none" id="GenericDraweeHierarchy-backto-RootDrawable" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="766.5,395,762.5,401,766.5,407,770.5,401,766.5,395" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DraweeController to SimpleDraweeView--><g id="link_DraweeController_SimpleDraweeView"><path codeLine="31" d="M372.5097,289.3343 C330.5527,307.0533 278.328,329.108 236.29,346.862 " fill="none" id="DraweeController-backto-SimpleDraweeView" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="378.037,287,368.1899,286.8165,373.4309,288.9452,371.3022,294.1863,378.037,287" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DraweeController to AbstractDraweeController--><g id="link_DraweeController_AbstractDraweeController"><path codeLine="33" d="M432.5,305 C432.5,322.658 432.5,328.941 432.5,346.678 " fill="none" id="DraweeController-backto-AbstractDraweeController" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="432.5,287,426.5,305,438.5,305,432.5,287" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link AbstractDraweeController to PipelineDraweeController--><g id="link_AbstractDraweeController_PipelineDraweeController"><path codeLine="34" d="M432.5,413 C432.5,430.6584 432.5,436.9408 432.5,454.6784 " fill="none" id="AbstractDraweeController-backto-PipelineDraweeController" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="432.5,395,426.5,413,438.5,413,432.5,395" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[TL91JiCm4BplArRY0fNy0LHLGaMYI1mGHRqxxf9OREF8SOaguEyuCMtSEBx5kpFZcOoTASbLPF4R49yFigITfWwNFqBWevKT3MU_KopRDXejdwWcgrMOR3HPQLLrMdde20ewLyWhkQq-D4mH_ePrMRc2Z-Gn2I_8JKdm2-366BfsP3-a8fnO6o8YUk2xQLxeYxW7o8BfzWxlyNpmSgF4bfphXnCf2FRdVm5aIBtxlUbgaUFv75FpQrCxQvZ9meoQoFg3kAwDuJtPR64n21UNtjEhpmXCRXjjxtIh2ytQdTQIkP3g4z9H_Bo2AaGbBoOhc3S-M7qpnbsAW-GvYMCZLcaUMRJEIkNmuVyZatWS1CTPU6uHQA-w8TOrJRT_]--></g></svg>

<h2 id="图片加载过程"><a href="#图片加载过程" class="headerlink" title="图片加载过程"></a>图片加载过程</h2><p>这个时序图是以文章开头的<code>SimpleDraweeView</code>的示例代码为例进行绘制。</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="1171px" preserveAspectRatio="none" style="width:1101px;height:1171px;background:#FFFFFF;" version="1.1" viewBox="0 0 1101 1171" width="1101px" zoomAndPan="magnify"><defs/><g><rect fill="#FFFFFF" height="29.1328" style="stroke:#181818;stroke-width:1.0;" width="10" x="201" y="97.6953"/><rect fill="#FFFFFF" height="101.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="201" y="183.2578"/><rect fill="#FFFFFF" height="64.1328" style="stroke:#181818;stroke-width:1.0;" width="10" x="206" y="220.3906"/><rect fill="#FFFFFF" height="473.8594" style="stroke:#181818;stroke-width:1.0;" width="10" x="386.5" y="515.5859"/><rect fill="#FFFFFF" height="406.7266" style="stroke:#181818;stroke-width:1.0;" width="10" x="391.5" y="582.7188"/><rect fill="#FFFFFF" height="278.1953" style="stroke:#181818;stroke-width:1.0;" width="10" x="396.5" y="682.1172"/><rect fill="#FFFFFF" height="108.3984" style="stroke:#181818;stroke-width:1.0;" width="10" x="386.5" y="1018.5781"/><rect fill="#FFFFFF" height="80.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="553.5" y="254.5234"/><rect fill="#FFFFFF" height="101.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="553.5" y="444.3203"/><rect fill="#FFFFFF" height="64.1328" style="stroke:#181818;stroke-width:1.0;" width="10" x="558.5" y="481.4531"/><rect fill="#FFFFFF" height="244.0625" style="stroke:#181818;stroke-width:1.0;" width="10" x="851.5" y="716.25"/><rect fill="#FFFFFF" height="164.7969" style="stroke:#181818;stroke-width:1.0;" width="10" x="856.5" y="795.5156"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="206" x2="206" y1="36.2969" y2="1135.9766"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="391" x2="391" y1="136.3438" y2="1135.9766"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="558" x2="558" y1="36.2969" y2="1135.9766"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="730.5" x2="730.5" y1="36.2969" y2="1135.9766"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="856.5" x2="856.5" y1="36.2969" y2="1135.9766"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="1022" x2="1022" y1="840.6484" y2="1135.9766"/><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="152" x="130" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="138" x="137" y="24.9951">SimpleDraweeView</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="152" x="130" y="1134.9766"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="138" x="137" y="1154.9717">SimpleDraweeView</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="199" x="292" y="1134.9766"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="185" x="299" y="1154.9717">PipelineDraweeController</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="115" x="501" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="101" x="508" y="24.9951">DraweeHolder</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="115" x="501" y="1134.9766"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="101" x="508" y="1154.9717">DraweeHolder</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="116" x="672.5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="102" x="679.5" y="24.9951">RootDrawable</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="116" x="672.5" y="1134.9766"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="102" x="679.5" y="1154.9717">RootDrawable</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="116" x="798.5" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="102" x="805.5" y="24.9951">ImagePipeline</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="116" x="798.5" y="1134.9766"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="102" x="805.5" y="1154.9717">ImagePipeline</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="97" x="974" y="1134.9766"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="83" x="981" y="1154.9717">DataSource</text><rect fill="#FFFFFF" height="29.1328" style="stroke:#181818;stroke-width:1.0;" width="10" x="201" y="97.6953"/><rect fill="#FFFFFF" height="101.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="201" y="183.2578"/><rect fill="#FFFFFF" height="64.1328" style="stroke:#181818;stroke-width:1.0;" width="10" x="206" y="220.3906"/><rect fill="#FFFFFF" height="473.8594" style="stroke:#181818;stroke-width:1.0;" width="10" x="386.5" y="515.5859"/><rect fill="#FFFFFF" height="406.7266" style="stroke:#181818;stroke-width:1.0;" width="10" x="391.5" y="582.7188"/><rect fill="#FFFFFF" height="278.1953" style="stroke:#181818;stroke-width:1.0;" width="10" x="396.5" y="682.1172"/><rect fill="#FFFFFF" height="108.3984" style="stroke:#181818;stroke-width:1.0;" width="10" x="386.5" y="1018.5781"/><rect fill="#FFFFFF" height="80.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="553.5" y="254.5234"/><rect fill="#FFFFFF" height="101.2656" style="stroke:#181818;stroke-width:1.0;" width="10" x="553.5" y="444.3203"/><rect fill="#FFFFFF" height="64.1328" style="stroke:#181818;stroke-width:1.0;" width="10" x="558.5" y="481.4531"/><rect fill="#FFFFFF" height="244.0625" style="stroke:#181818;stroke-width:1.0;" width="10" x="851.5" y="716.25"/><rect fill="#FFFFFF" height="164.7969" style="stroke:#181818;stroke-width:1.0;" width="10" x="856.5" y="795.5156"/><ellipse cx="7.5" cy="96.9453" fill="none" rx="4" ry="4" style="stroke:#181818;stroke-width:1.5;"/><polygon fill="#181818" points="189,93.6953,199,97.6953,189,101.6953,193,97.6953" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="12" x2="195" y1="97.6953" y2="97.6953"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="96" x="15" y="62.3638">setImageURI();</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="174" x="15" y="77.4966">Framework.onViewCreated</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="39" x="15" y="92.6294">&#20013;&#35843;&#29992;</text><polygon fill="#181818" points="280,122.8281,290,126.8281,280,130.8281,284,126.8281" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="206" x2="286" y1="126.8281" y2="126.8281"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="26" x="213" y="121.7622">&#26500;&#36896;</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="199" x="292" y="105.6953"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="185" x="299" y="125.6904">PipelineDraweeController</text><ellipse cx="7.5" cy="182.5078" fill="none" rx="4" ry="4" style="stroke:#181818;stroke-width:1.5;"/><polygon fill="#181818" points="189,179.2578,199,183.2578,189,187.2578,193,183.2578" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="12" x2="195" y1="183.2578" y2="183.2578"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="141" x="15" y="163.0591">onAttachedToWindow</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="78" x="15" y="178.1919">&#65288;&#29238;&#31867;&#26041;&#27861;&#65289;</text><line style="stroke:#181818;stroke-width:1.0;" x1="211" x2="258" y1="207.3906" y2="207.3906"/><line style="stroke:#181818;stroke-width:1.0;" x1="258" x2="258" y1="207.3906" y2="220.3906"/><line style="stroke:#181818;stroke-width:1.0;" x1="217" x2="258" y1="220.3906" y2="220.3906"/><polygon fill="#181818" points="227,216.3906,217,220.3906,227,224.3906,223,220.3906" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="58" x="223" y="202.3247">onAttach</text><polygon fill="#181818" points="541.5,250.5234,551.5,254.5234,541.5,258.5234,545.5,254.5234" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="216" x2="547.5" y1="254.5234" y2="254.5234"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="58" x="223" y="249.4575">onAttach</text><line style="stroke:#181818;stroke-width:1.0;" x1="563.5" x2="605.5" y1="333.7891" y2="333.7891"/><line style="stroke:#181818;stroke-width:1.0;" x1="605.5" x2="605.5" y1="333.7891" y2="346.7891"/><line style="stroke:#181818;stroke-width:1.0;" x1="558.5" x2="605.5" y1="346.7891" y2="346.7891"/><polygon fill="#181818" points="568.5,342.7891,558.5,346.7891,568.5,350.7891,564.5,346.7891" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="148" x="570.5" y="313.5903">&#27492;&#26102;&#36824;&#26410;&#35774;&#32622;visible,&#19981;&#20250;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="129" x="570.5" y="328.7231">&#35843;&#29992;attachController</text><ellipse cx="7.5" cy="385.3047" fill="none" rx="4" ry="4" style="stroke:#181818;stroke-width:1.5;"/><polygon fill="#181818" points="194,382.0547,204,386.0547,194,390.0547,198,386.0547" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="12" x2="200" y1="386.0547" y2="386.0547"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="143" x="15" y="365.856">onVisibilityAggregated</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="146" x="15" y="380.9888">(&#29238;&#31867;ImageView&#30340;&#26041;&#27861;)</text><polygon fill="#181818" points="718.5,411.1875,728.5,415.1875,718.5,419.1875,722.5,415.1875" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="206" x2="724.5" y1="415.1875" y2="415.1875"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="61" x="213" y="410.1216">setVisible</text><polygon fill="#181818" points="574.5,440.3203,564.5,444.3203,574.5,448.3203,570.5,444.3203" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="568.5" x2="729.5" y1="444.3203" y2="444.3203"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="117" x="580.5" y="439.2544">onVisibilityChange</text><line style="stroke:#181818;stroke-width:1.0;" x1="563.5" x2="610.5" y1="468.4531" y2="468.4531"/><line style="stroke:#181818;stroke-width:1.0;" x1="610.5" x2="610.5" y1="468.4531" y2="481.4531"/><line style="stroke:#181818;stroke-width:1.0;" x1="569.5" x2="610.5" y1="481.4531" y2="481.4531"/><polygon fill="#181818" points="579.5,477.4531,569.5,481.4531,579.5,485.4531,575.5,481.4531" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="103" x="575.5" y="463.3872">attachController</text><polygon fill="#181818" points="407.5,511.5859,397.5,515.5859,407.5,519.5859,403.5,515.5859" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="401.5" x2="557.5" y1="515.5859" y2="515.5859"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="58" x="413.5" y="510.52">onAttach</text><line style="stroke:#181818;stroke-width:1.0;" x1="396.5" x2="443.5" y1="569.7188" y2="569.7188"/><line style="stroke:#181818;stroke-width:1.0;" x1="443.5" x2="443.5" y1="569.7188" y2="582.7188"/><line style="stroke:#181818;stroke-width:1.0;" x1="402.5" x2="443.5" y1="582.7188" y2="582.7188"/><polygon fill="#181818" points="412.5,578.7188,402.5,582.7188,412.5,586.7188,408.5,582.7188" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="97" x="408.5" y="564.6528">submitRequest</text><line style="stroke:#181818;stroke-width:1.0;" x1="401.5" x2="443.5" y1="631.9844" y2="631.9844"/><line style="stroke:#181818;stroke-width:1.0;" x1="443.5" x2="443.5" y1="631.9844" y2="644.9844"/><line style="stroke:#181818;stroke-width:1.0;" x1="402.5" x2="443.5" y1="644.9844" y2="644.9844"/><polygon fill="#181818" points="412.5,640.9844,402.5,644.9844,412.5,648.9844,408.5,644.9844" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="109" x="408.5" y="611.7856">getCachedImage</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="97" x="408.5" y="626.9185">&#33719;&#21462;&#32531;&#23384;Bitmap</text><line style="stroke:#181818;stroke-width:1.0;" x1="401.5" x2="448.5" y1="669.1172" y2="669.1172"/><line style="stroke:#181818;stroke-width:1.0;" x1="448.5" x2="448.5" y1="669.1172" y2="682.1172"/><line style="stroke:#181818;stroke-width:1.0;" x1="407.5" x2="448.5" y1="682.1172" y2="682.1172"/><polygon fill="#181818" points="417.5,678.1172,407.5,682.1172,417.5,686.1172,413.5,682.1172" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="96" x="413.5" y="664.0513">getDataSource</text><polygon fill="#181818" points="839.5,712.25,849.5,716.25,839.5,720.25,843.5,716.25" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="406.5" x2="845.5" y1="716.25" y2="716.25"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="130" x="413.5" y="711.1841">fetchDecodedImage</text><line style="stroke:#181818;stroke-width:1.0;" x1="861.5" x2="903.5" y1="745.3828" y2="745.3828"/><line style="stroke:#181818;stroke-width:1.0;" x1="903.5" x2="903.5" y1="745.3828" y2="758.3828"/><line style="stroke:#181818;stroke-width:1.0;" x1="862.5" x2="903.5" y1="758.3828" y2="758.3828"/><polygon fill="#181818" points="872.5,754.3828,862.5,758.3828,872.5,762.3828,868.5,758.3828" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="91" x="868.5" y="740.3169">&#29983;&#25104;&#29983;&#20135;&#32773;&#24207;&#21015;</text><line style="stroke:#181818;stroke-width:1.0;" x1="861.5" x2="908.5" y1="782.5156" y2="782.5156"/><line style="stroke:#181818;stroke-width:1.0;" x1="908.5" x2="908.5" y1="782.5156" y2="795.5156"/><line style="stroke:#181818;stroke-width:1.0;" x1="867.5" x2="908.5" y1="795.5156" y2="795.5156"/><polygon fill="#181818" points="877.5,791.5156,867.5,795.5156,877.5,799.5156,873.5,795.5156" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="142" x="873.5" y="777.4497">submitFetchRequest()</text><polygon fill="#181818" points="962,840.7813,972,844.7813,962,848.7813,966,844.7813" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="866.5" x2="968" y1="844.7813" y2="844.7813"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="65" x="873.5" y="824.5825">&#26500;&#36896;&#26102;&#20256;&#20837;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="65" x="873.5" y="839.7153">&#29983;&#20135;&#32773;&#38431;&#21015;</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="97" x="974" y="811.4844"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="83" x="981" y="831.4795">DataSource</text><line style="stroke:#181818;stroke-width:1.0;" x1="1022.5" x2="1064.5" y1="889.0469" y2="889.0469"/><line style="stroke:#181818;stroke-width:1.0;" x1="1064.5" x2="1064.5" y1="889.0469" y2="902.0469"/><line style="stroke:#181818;stroke-width:1.0;" x1="1023.5" x2="1064.5" y1="902.0469" y2="902.0469"/><polygon fill="#181818" points="1033.5,898.0469,1023.5,902.0469,1033.5,906.0469,1029.5,902.0469" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="65" x="1029.5" y="868.8481">&#29983;&#20135;&#32773;&#38431;&#21015;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="52" x="1029.5" y="883.981">&#21551;&#21160;&#25191;&#34892;</text><polygon fill="#181818" points="877.5,927.1797,867.5,931.1797,877.5,935.1797,873.5,931.1797" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" x1="871.5" x2="1021.5" y1="931.1797" y2="931.1797"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="52" x="883.5" y="926.1138">&#36820;&#22238;&#23454;&#20363;</text><polygon fill="#181818" points="412.5,956.3125,402.5,960.3125,412.5,964.3125,408.5,960.3125" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" x1="406.5" x2="855.5" y1="960.3125" y2="960.3125"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="375" x="418.5" y="955.2466">&#36820;&#22238; DataSource&lt;CloseableReference&lt;CloseableImage&gt;&gt;</text><polygon fill="#181818" points="1010.5,985.4453,1020.5,989.4453,1010.5,993.4453,1014.5,989.4453" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="391.5" x2="1016.5" y1="989.4453" y2="989.4453"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="242" x="398.5" y="984.3794">&#160;&#160;subscribe(DataSubscriber)&#27880;&#20876;&#35746;&#38405;&#32773;</text><polygon fill="#181818" points="407.5,1014.5781,397.5,1018.5781,407.5,1022.5781,403.5,1018.5781" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="401.5" x2="1021.5" y1="1018.5781" y2="1018.5781"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="343" x="413.5" y="1013.5122">&#36820;&#22238;&#22270;&#29255;Bitmap&#12290;&#29238;&#31867;&#30340;onNewResultInternal()&#20250;&#34987;&#25191;&#34892;</text><line style="stroke:#181818;stroke-width:1.0;" x1="396.5" x2="438.5" y1="1047.7109" y2="1047.7109"/><line style="stroke:#181818;stroke-width:1.0;" x1="438.5" x2="438.5" y1="1047.7109" y2="1060.7109"/><line style="stroke:#181818;stroke-width:1.0;" x1="397.5" x2="438.5" y1="1060.7109" y2="1060.7109"/><polygon fill="#181818" points="407.5,1056.7109,397.5,1060.7109,407.5,1064.7109,403.5,1060.7109" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="102" x="403.5" y="1042.645">createDrawable</text><line style="stroke:#181818;stroke-width:1.0;" x1="396.5" x2="438.5" y1="1104.9766" y2="1104.9766"/><line style="stroke:#181818;stroke-width:1.0;" x1="438.5" x2="438.5" y1="1104.9766" y2="1117.9766"/><line style="stroke:#181818;stroke-width:1.0;" x1="397.5" x2="438.5" y1="1117.9766" y2="1117.9766"/><polygon fill="#181818" points="407.5,1113.9766,397.5,1117.9766,407.5,1121.9766,403.5,1117.9766" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="134" x="403.5" y="1084.7778">hierarchy.setImage()</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="52" x="403.5" y="1099.9106">&#26174;&#31034;&#22270;&#29255;</text><!--SRC=[dLLDJnD16BxlhzZ4nBJK4hruA8O4IuXSZ2cA1_OoR5_QYTkPEftIS2CAs2eAYGWD6422WMYe6X94hEN7sFtWn5zmThUbk_rOII-RxCpxFEypppCVKpGwB4_WJ5Q3KOOA09CO2d8a4fDpmCSpA0LF4kEXy912nXZAG86oPuEKs4Ln1eX3KY7rqoFh-qjpxL3gu17SZt0MD4mQet5AEAEQ1amU691Zih6zS36_AoK1gHpF2huEBP8qrLCY9IES8pKDoSVqAIP9Mb38PRLe5a_C7x-DzL_6yOVBQgchh6vyJRgk0FVl0TMIGhktUQ3ue3aVOtk7Q5IOSxHlR9nOvsNZunUhKZF_L6Pn3azhSAj- -hPUtLI8wpjoTBIixU6OBNdI9i0QvdCZgHI3b9jWo7NCYTikDJSNNFV2NQr8KChj4IIaEFjaqfKbUITwUDOI44yZae9W5snCn-hQ4JrtM2HYkzWj9o-5r1CVmEqSaFnq1lC4FCz3ZlV58Y990OyxEzWnNoJwxgU-icvMt-j7vVkOPr2sFsPReE0UHHnDq3nJ8P36QTuiSB0pmDNqAAWqsP0c-MiwG37PNDinYglYMpyxiEONzRCLlRZnFrZBo36xOyFDKBWJrrgAz-eG1wHUtTKNFolaglD5USVkx07uuOvKRwb2zDLl-kj3etHWVLhs0RkiqpfVqxUszSfslVQcNMPG9D7e5TYZvbvSepcmJqm2Pe01yGuvxCF3tgthQ-YTwDKtC7YVApTltBbxUyZzYanoAiFJ479AcdyiR1mVwalBLcNlehme3BoMWklK-DCAtDUD0BPgPkcLUqR-phzmhp1nSr7o40e9oEKrFauuC8AqK5ZSbjRUrqQ-VHvLrNdmclTRlonf30mnDJqts7nWGs656EMQkN_cBkaV]--></g></svg>

<p>上图中DateSource是一个<code>CloseableProducerToDataSourceAdapter</code>实例，如下图类图所示：</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="428px" preserveAspectRatio="none" style="width:977px;height:428px;background:#FFFFFF;" version="1.1" viewBox="0 0 977 428" width="977px" zoomAndPan="magnify"><defs/><g><!--class DataSource--><g id="elem_DataSource"><rect codeLine="1" fill="#F1F1F1" height="48" id="DataSource" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="349" x="478.5" y="10"/><ellipse cx="493.5" cy="26" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M495.8438,21.6719 C494.9063,21.2344 494.3125,21.0938 493.4375,21.0938 C490.8125,21.0938 488.8125,23.1719 488.8125,25.8906 L488.8125,27.0156 C488.8125,29.5938 490.9219,31.4844 493.8125,31.4844 C495.0313,31.4844 496.1875,31.1875 496.9375,30.6406 C497.5156,30.2344 497.8438,29.7813 497.8438,29.3906 C497.8438,28.9375 497.4531,28.5469 496.9844,28.5469 C496.7656,28.5469 496.5625,28.625 496.375,28.8125 C495.9219,29.2969 495.9219,29.2969 495.7344,29.3906 C495.3125,29.6563 494.625,29.7813 493.8594,29.7813 C491.8125,29.7813 490.5156,28.6875 490.5156,26.9844 L490.5156,25.8906 C490.5156,24.1094 491.7656,22.7969 493.5,22.7969 C494.0781,22.7969 494.6875,22.9531 495.1563,23.2031 C495.6406,23.4844 495.8125,23.7031 495.9063,24.1094 C495.9688,24.5156 496,24.6406 496.1406,24.7656 C496.2813,24.9063 496.5156,25.0156 496.7344,25.0156 C497,25.0156 497.2656,24.875 497.4375,24.6563 C497.5469,24.5 497.5781,24.3125 497.5781,23.8906 L497.5781,22.4688 C497.5781,22.0313 497.5625,21.9063 497.4688,21.75 C497.3125,21.4844 497.0313,21.3438 496.7344,21.3438 C496.4375,21.3438 496.2344,21.4375 496.0156,21.75 L495.8438,21.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="83" x="507.5" y="30.8467">DataSource</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="232" x="598.5" y="7"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="230" x="599.5" y="19.1387">CloseableReference&lt;CloseableImage&gt;</text><line style="stroke:#181818;stroke-width:0.5;" x1="479.5" x2="826.5" y1="42" y2="42"/><line style="stroke:#181818;stroke-width:0.5;" x1="479.5" x2="826.5" y1="50" y2="50"/></g><!--class Producer--><g id="elem_Producer"><rect codeLine="2" fill="#F1F1F1" height="64.2969" id="Producer" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="401" x="12.5" y="357"/><ellipse cx="59.75" cy="373" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M62.0938,368.6719 C61.1563,368.2344 60.5625,368.0938 59.6875,368.0938 C57.0625,368.0938 55.0625,370.1719 55.0625,372.8906 L55.0625,374.0156 C55.0625,376.5938 57.1719,378.4844 60.0625,378.4844 C61.2813,378.4844 62.4375,378.1875 63.1875,377.6406 C63.7656,377.2344 64.0938,376.7813 64.0938,376.3906 C64.0938,375.9375 63.7031,375.5469 63.2344,375.5469 C63.0156,375.5469 62.8125,375.625 62.625,375.8125 C62.1719,376.2969 62.1719,376.2969 61.9844,376.3906 C61.5625,376.6563 60.875,376.7813 60.1094,376.7813 C58.0625,376.7813 56.7656,375.6875 56.7656,373.9844 L56.7656,372.8906 C56.7656,371.1094 58.0156,369.7969 59.75,369.7969 C60.3281,369.7969 60.9375,369.9531 61.4063,370.2031 C61.8906,370.4844 62.0625,370.7031 62.1563,371.1094 C62.2188,371.5156 62.25,371.6406 62.3906,371.7656 C62.5313,371.9063 62.7656,372.0156 62.9844,372.0156 C63.25,372.0156 63.5156,371.875 63.6875,371.6563 C63.7969,371.5 63.8281,371.3125 63.8281,370.8906 L63.8281,369.4688 C63.8281,369.0313 63.8125,368.9063 63.7188,368.75 C63.5625,368.4844 63.2813,368.3438 62.9844,368.3438 C62.6875,368.3438 62.4844,368.4375 62.2656,368.75 L62.0938,368.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="64" x="80.25" y="377.8467">Producer</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="232" x="184.5" y="354"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="230" x="185.5" y="366.1387">CloseableReference&lt;CloseableImage&gt;</text><line style="stroke:#181818;stroke-width:0.5;" x1="13.5" x2="412.5" y1="389" y2="389"/><line style="stroke:#181818;stroke-width:0.5;" x1="13.5" x2="412.5" y1="397" y2="397"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="389" x="18.5" y="413.9951">void produceResults(Consumer&lt;T&gt;, ProducerContext)</text></g><!--class AbstractDataSource--><g id="elem_AbstractDataSource"><rect codeLine="5" fill="#F1F1F1" height="48" id="AbstractDataSource" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="409" x="448.5" y="119"/><ellipse cx="463.5" cy="135" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M465.5781,136.8125 L465.9688,137.7969 L465.5781,137.7969 C465.125,137.7969 465.0156,137.8125 464.8594,137.9219 C464.6094,138.0781 464.4531,138.3594 464.4531,138.6563 C464.4531,138.9219 464.5938,139.1719 464.8125,139.3281 C464.9531,139.4531 465.1563,139.5 465.5781,139.5 L467.9375,139.5 C468.2969,139.5 468.5156,139.4688 468.6563,139.375 C468.9063,139.2344 469.0625,138.9375 469.0625,138.6563 C469.0625,138.375 468.9219,138.125 468.7031,137.9688 C468.5313,137.8281 468.375,137.7969 467.9063,137.7969 L464.5156,129.5938 L460.8438,129.5938 C460.3906,129.5938 460.2656,129.6094 460.1094,129.7031 C459.8594,129.875 459.7031,130.1563 459.7031,130.4375 C459.7031,130.7188 459.8438,130.9688 460.0625,131.1406 C460.2344,131.25 460.4063,131.2813 460.8438,131.2813 L461.9219,131.2813 L459.2813,137.7969 C458.8594,137.7969 458.7031,137.8125 458.5469,137.9219 C458.2969,138.0781 458.1406,138.3594 458.1406,138.6563 C458.1406,139.2188 458.5156,139.5 459.2656,139.5 L461.5313,139.5 C461.8906,139.5 462.1094,139.4688 462.2344,139.375 C462.5,139.2344 462.6406,138.9375 462.6406,138.6563 C462.6406,138.375 462.5156,138.125 462.2969,137.9531 C462.125,137.8281 461.9844,137.7969 461.5313,137.7969 L461.1406,137.7969 L461.5313,136.8125 L465.5781,136.8125 Z M464.875,135.1094 L462.2031,135.1094 L463.5469,131.8438 L464.875,135.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="143" x="477.5" y="139.8467">AbstractDataSource</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="232" x="628.5" y="116"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="230" x="629.5" y="128.1387">CloseableReference&lt;CloseableImage&gt;</text><line style="stroke:#181818;stroke-width:0.5;" x1="449.5" x2="856.5" y1="151" y2="151"/><line style="stroke:#181818;stroke-width:0.5;" x1="449.5" x2="856.5" y1="159" y2="159"/></g><!--class AbstractProducerToDataSourceAdapter--><g id="elem_AbstractProducerToDataSourceAdapter"><rect codeLine="6" fill="#F1F1F1" height="48" id="AbstractProducerToDataSourceAdapter" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="548" x="7" y="228"/><ellipse cx="22" cy="244" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M24.0781,245.8125 L24.4688,246.7969 L24.0781,246.7969 C23.625,246.7969 23.5156,246.8125 23.3594,246.9219 C23.1094,247.0781 22.9531,247.3594 22.9531,247.6563 C22.9531,247.9219 23.0938,248.1719 23.3125,248.3281 C23.4531,248.4531 23.6563,248.5 24.0781,248.5 L26.4375,248.5 C26.7969,248.5 27.0156,248.4688 27.1563,248.375 C27.4063,248.2344 27.5625,247.9375 27.5625,247.6563 C27.5625,247.375 27.4219,247.125 27.2031,246.9688 C27.0313,246.8281 26.875,246.7969 26.4063,246.7969 L23.0156,238.5938 L19.3438,238.5938 C18.8906,238.5938 18.7656,238.6094 18.6094,238.7031 C18.3594,238.875 18.2031,239.1563 18.2031,239.4375 C18.2031,239.7188 18.3438,239.9688 18.5625,240.1406 C18.7344,240.25 18.9063,240.2813 19.3438,240.2813 L20.4219,240.2813 L17.7813,246.7969 C17.3594,246.7969 17.2031,246.8125 17.0469,246.9219 C16.7969,247.0781 16.6406,247.3594 16.6406,247.6563 C16.6406,248.2188 17.0156,248.5 17.7656,248.5 L20.0313,248.5 C20.3906,248.5 20.6094,248.4688 20.7344,248.375 C21,248.2344 21.1406,247.9375 21.1406,247.6563 C21.1406,247.375 21.0156,247.125 20.7969,246.9531 C20.625,246.8281 20.4844,246.7969 20.0313,246.7969 L19.6406,246.7969 L20.0313,245.8125 L24.0781,245.8125 Z M23.375,244.1094 L20.7031,244.1094 L22.0469,240.8438 L23.375,244.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="282" x="36" y="248.8467">AbstractProducerToDataSourceAdapter</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="232" x="326" y="225"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="230" x="327" y="237.1387">CloseableReference&lt;CloseableImage&gt;</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="554" y1="260" y2="260"/><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="554" y1="268" y2="268"/></g><!--class CloseableProducerToDataSourceAdapter--><g id="elem_CloseableProducerToDataSourceAdapter"><rect codeLine="7" fill="#F1F1F1" height="48" id="CloseableProducerToDataSourceAdapter" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="424" x="457" y="365"/><ellipse cx="472" cy="381" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M474.3438,376.6719 C473.4063,376.2344 472.8125,376.0938 471.9375,376.0938 C469.3125,376.0938 467.3125,378.1719 467.3125,380.8906 L467.3125,382.0156 C467.3125,384.5938 469.4219,386.4844 472.3125,386.4844 C473.5313,386.4844 474.6875,386.1875 475.4375,385.6406 C476.0156,385.2344 476.3438,384.7813 476.3438,384.3906 C476.3438,383.9375 475.9531,383.5469 475.4844,383.5469 C475.2656,383.5469 475.0625,383.625 474.875,383.8125 C474.4219,384.2969 474.4219,384.2969 474.2344,384.3906 C473.8125,384.6563 473.125,384.7813 472.3594,384.7813 C470.3125,384.7813 469.0156,383.6875 469.0156,381.9844 L469.0156,380.8906 C469.0156,379.1094 470.2656,377.7969 472,377.7969 C472.5781,377.7969 473.1875,377.9531 473.6563,378.2031 C474.1406,378.4844 474.3125,378.7031 474.4063,379.1094 C474.4688,379.5156 474.5,379.6406 474.6406,379.7656 C474.7813,379.9063 475.0156,380.0156 475.2344,380.0156 C475.5,380.0156 475.7656,379.875 475.9375,379.6563 C476.0469,379.5 476.0781,379.3125 476.0781,378.8906 L476.0781,377.4688 C476.0781,377.0313 476.0625,376.9063 475.9688,376.75 C475.8125,376.4844 475.5313,376.3438 475.2344,376.3438 C474.9375,376.3438 474.7344,376.4375 474.5156,376.75 L474.3438,376.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="294" x="486" y="385.8467">CloseableProducerToDataSourceAdapter</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="96" x="788" y="362"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="94" x="789" y="374.1387">CloseableImage</text><line style="stroke:#181818;stroke-width:0.5;" x1="458" x2="880" y1="397" y2="397"/><line style="stroke:#181818;stroke-width:0.5;" x1="458" x2="880" y1="405" y2="405"/></g><!--class DataSubscriber--><g id="elem_DataSubscriber"><rect codeLine="13" fill="#F1F1F1" height="48" id="DataSubscriber" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="376" x="590" y="228"/><ellipse cx="605" cy="244" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M605.9531,240.7813 L607.6719,240.7813 C608.0625,240.7813 608.25,240.75 608.375,240.6719 C608.6406,240.5156 608.7813,240.2344 608.7813,239.9375 C608.7813,239.6719 608.6719,239.4063 608.4375,239.2344 C608.2656,239.125 608.125,239.0938 607.6719,239.0938 L602.5313,239.0938 C602.0938,239.0938 601.9688,239.1094 601.8125,239.2031 C601.5625,239.3594 601.4063,239.6563 601.4063,239.9375 C601.4063,240.2188 601.5469,240.4688 601.7656,240.6406 C601.9219,240.75 602.1094,240.7813 602.5313,240.7813 L604.25,240.7813 L604.25,247.2969 L602.5313,247.2969 C602.0938,247.2969 601.9688,247.3125 601.8125,247.4219 C601.5625,247.5781 601.4063,247.8594 601.4063,248.1563 C601.4063,248.4063 601.5469,248.6719 601.7656,248.8281 C601.9219,248.9531 602.125,249 602.5313,249 L607.6719,249 C608.4219,249 608.7813,248.7188 608.7813,248.1563 C608.7813,247.875 608.6719,247.625 608.4375,247.4531 C608.2656,247.3281 608.125,247.2969 607.6719,247.2969 L605.9531,247.2969 L605.9531,240.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="110" x="619" y="248.8467">DataSubscriber</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="232" x="737" y="225"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="230" x="738" y="237.1387">CloseableReference&lt;CloseableImage&gt;</text><line style="stroke:#181818;stroke-width:0.5;" x1="591" x2="965" y1="260" y2="260"/><line style="stroke:#181818;stroke-width:0.5;" x1="591" x2="965" y1="268" y2="268"/></g><!--reverse link DataSource to AbstractDataSource--><g id="link_DataSource_AbstractDataSource"><path codeLine="8" d="M653,76.217 C653,94.165 653,100.892 653,118.828 " fill="none" id="DataSource-backto-AbstractDataSource" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="653,58.217,647,76.217,659,76.217,653,58.217" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link AbstractDataSource to AbstractProducerToDataSourceAdapter--><g id="link_AbstractDataSource_AbstractProducerToDataSourceAdapter"><path codeLine="9" d="M555.4413,172.0615 C492.8593,190.0615 423.662,209.966 361.117,227.956 " fill="none" id="AbstractDataSource-backto-AbstractProducerToDataSourceAdapter" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="572.74,167.086,553.7828,166.2953,557.0998,177.8277,572.74,167.086" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link AbstractProducerToDataSourceAdapter to CloseableProducerToDataSourceAdapter--><g id="link_AbstractProducerToDataSourceAdapter_CloseableProducerToDataSourceAdapter"><path codeLine="10" d="M406.7091,280.351 C440.0571,288.553 459.151,294.381 492,306 C538.775,322.544 589.98,347.0071 625.226,364.9074 " fill="none" id="AbstractProducerToDataSourceAdapter-backto-CloseableProducerToDataSourceAdapter" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="389.23,276.052,405.2761,286.1774,408.1421,274.5247,389.23,276.052" style="stroke:#181818;stroke-width:1.0;"/></g><!--link AbstractProducerToDataSourceAdapter to Producer--><g id="link_AbstractProducerToDataSourceAdapter_Producer"><path codeLine="11" d="M236.869,276.157 C226.12,284.084 215.998,294.037 210,306 C202.849,320.263 201.7812,331.7876 203.6842,346.9377 " fill="none" id="AbstractProducerToDataSourceAdapter-to-Producer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="204.432,352.8909,207.2791,343.4625,203.8088,347.9299,199.3415,344.4596,204.432,352.8909" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="26" x="211" y="319.0669">&#20381;&#36182;</text></g><!--link AbstractProducerToDataSourceAdapter to Producer--><g id="link_AbstractProducerToDataSourceAdapter_Producer"><path codeLine="12" d="M331.172,276.183 C361.05,292.931 396.466,318.65 414,353 C425.317,375.1714 445.893,409 421,409 " fill="none" id="AbstractProducerToDataSourceAdapter-to-Producer-1" style="stroke:#0000FF;stroke-width:1.0;stroke-dasharray:7.0,7.0;"/><polygon fill="#0000FF" points="415,409,424,413,420,409,424,405,415,409" style="stroke:#0000FF;stroke-width:1.0;"/><text fill="#0000FF" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="91" x="392" y="319.0669">&#26500;&#36896;&#20989;&#25968;&#20013;&#35843;&#29992;</text></g><!--reverse link AbstractDataSource to DataSubscriber--><g id="link_AbstractDataSource_DataSubscriber"><path codeLine="14" d="M689.2392,175.0206 C710.2062,192.9686 729.976,209.892 750.93,227.828 " fill="none" id="AbstractDataSource-backto-DataSubscriber" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="680.123,167.217,682.0799,174.1575,689.2392,175.0206,687.2823,168.0801,680.123,167.217" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="8" x="677.7592" y="187.0311">1</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="8" x="734.9683" y="216.796">n</text></g><!--SRC=[Iyv9B2vMS4aiIGpEBorAJhLnpialJarCoaaDIarBBKhDGnRop4rCJxMpuqe6QmeeoayfJKuj8aQBGZMN0X2KvMUcA1H0z0Mb5fVcb1HhEEVd5PVc0eq9iTE1cmaKB4cjAD7agkLAJ2ekAKfCBb5mX398T2o6VfWT8Va8annJ4WjAYFCArFTmOQACW-ZbGgXGiAdHrSNY9IvC8LIbUApZ8a8Dn31Y74-KQRgwTl0uKx1IUB9lxekjqqZMQMM5cYOKb9DoIbEjSpBpKlLI4eipKbEiGQd12YGAjENPl9QN3GkUjkzzDdN3anrhNsneVZvb1LScCCKKfIK2mmjiMMbISN9HPXAHSOebr9KCbHIqW66bbAU4PY80]--></g></svg>

<p>Producer就是图片的生产者队列，会执行网络请求、缓存读写、图片解码等等图片处理任务。下文会详细介绍生产者队列。</p>
<h3 id="PipelineDraweeController的构造过程"><a href="#PipelineDraweeController的构造过程" class="headerlink" title="PipelineDraweeController的构造过程"></a>PipelineDraweeController的构造过程</h3><?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="609px" preserveAspectRatio="none" style="width:982px;height:609px;background:#FFFFFF;" version="1.1" viewBox="0 0 982 609" width="982px" zoomAndPan="magnify"><defs/><g><rect fill="#FFFFFF" height="114.6953" style="stroke:#181818;stroke-width:1.0;" width="10" x="108" y="67.4297"/><rect fill="#FFFFFF" height="353.7578" style="stroke:#181818;stroke-width:1.0;" width="10" x="108" y="211.2578"/><rect fill="#FFFFFF" height="85.5625" style="stroke:#181818;stroke-width:1.0;" width="10" x="348.5" y="96.5625"/><rect fill="#FFFFFF" height="266.3594" style="stroke:#181818;stroke-width:1.0;" width="10" x="637.5" y="298.6563"/><rect fill="#FFFFFF" height="214.0938" style="stroke:#181818;stroke-width:1.0;" width="10" x="642.5" y="350.9219"/><rect fill="#FFFFFF" height="171.9609" style="stroke:#181818;stroke-width:1.0;" width="10" x="647.5" y="393.0547"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="113" x2="113" y1="36.2969" y2="574.0156"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="353" x2="353" y1="36.2969" y2="574.0156"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="642" x2="642" y1="135.2109" y2="574.0156"/><line style="stroke:#181818;stroke-width:0.5;stroke-dasharray:5.0,5.0;" x1="876" x2="876" y1="436.7031" y2="574.0156"/><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="152" x="37" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="138" x="44" y="24.9951">SimpleDraweeView</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="152" x="37" y="573.0156"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="138" x="44" y="593.0107">SimpleDraweeView</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="309" x="199" y="5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="295" x="206" y="24.9951">PipelineDraweeControllerBuilderSupplier</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="309" x="199" y="573.0156"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="295" x="206" y="593.0107">PipelineDraweeControllerBuilderSupplier</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="249" x="518" y="573.0156"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="235" x="525" y="593.0107">PipelineDraweeControllerBuilder</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="199" x="777" y="573.0156"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="185" x="784" y="593.0107">PipelineDraweeController</text><rect fill="#FFFFFF" height="114.6953" style="stroke:#181818;stroke-width:1.0;" width="10" x="108" y="67.4297"/><rect fill="#FFFFFF" height="353.7578" style="stroke:#181818;stroke-width:1.0;" width="10" x="108" y="211.2578"/><rect fill="#FFFFFF" height="85.5625" style="stroke:#181818;stroke-width:1.0;" width="10" x="348.5" y="96.5625"/><rect fill="#FFFFFF" height="266.3594" style="stroke:#181818;stroke-width:1.0;" width="10" x="637.5" y="298.6563"/><rect fill="#FFFFFF" height="214.0938" style="stroke:#181818;stroke-width:1.0;" width="10" x="642.5" y="350.9219"/><rect fill="#FFFFFF" height="171.9609" style="stroke:#181818;stroke-width:1.0;" width="10" x="647.5" y="393.0547"/><ellipse cx="7.5" cy="66.6797" fill="none" rx="4" ry="4" style="stroke:#181818;stroke-width:1.5;"/><polygon fill="#181818" points="96,63.4297,106,67.4297,96,71.4297,100,67.4297" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="12" x2="102" y1="67.4297" y2="67.4297"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="19" x="15" y="62.3638">init</text><polygon fill="#181818" points="336.5,92.5625,346.5,96.5625,336.5,100.5625,340.5,96.5625" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="118" x2="342.5" y1="96.5625" y2="96.5625"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="31" x="125" y="91.4966">get()</text><polygon fill="#181818" points="506,106.5625,516,110.5625,506,114.5625,510,110.5625" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="358.5" x2="512" y1="110.5625" y2="110.5625"/><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="249" x="518" y="104.5625"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="235" x="525" y="124.5576">PipelineDraweeControllerBuilder</text><polygon fill="#181818" points="124,178.125,114,182.125,124,186.125,120,182.125" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" x1="118" x2="352.5" y1="182.125" y2="182.125"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="26" x="130" y="161.9263">&#36820;&#22238;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="204" x="130" y="177.0591">PipelineDraweeControllerBuilder</text><ellipse cx="7.5" cy="210.5078" fill="none" rx="4" ry="4" style="stroke:#181818;stroke-width:1.5;"/><polygon fill="#181818" points="96,207.2578,106,211.2578,96,215.2578,100,211.2578" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="12" x2="102" y1="211.2578" y2="211.2578"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="81" x="15" y="206.1919">setImageURI</text><polygon fill="#181818" points="630.5,236.3906,640.5,240.3906,630.5,244.3906,634.5,240.3906" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="118" x2="636.5" y1="240.3906" y2="240.3906"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="47" x="125" y="235.3247">setUri()</text><polygon fill="#181818" points="630.5,265.5234,640.5,269.5234,630.5,273.5234,634.5,269.5234" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="118" x2="636.5" y1="269.5234" y2="269.5234"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="113" x="125" y="264.4575">setOldController()</text><polygon fill="#181818" points="625.5,294.6563,635.5,298.6563,625.5,302.6563,629.5,298.6563" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="118" x2="631.5" y1="298.6563" y2="298.6563"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="92" x="125" y="293.5903">&#35843;&#29992;&#29238;&#31867;build()</text><line style="stroke:#181818;stroke-width:1.0;" x1="647.5" x2="694.5" y1="337.9219" y2="337.9219"/><line style="stroke:#181818;stroke-width:1.0;" x1="694.5" x2="694.5" y1="337.9219" y2="350.9219"/><line style="stroke:#181818;stroke-width:1.0;" x1="653.5" x2="694.5" y1="350.9219" y2="350.9219"/><polygon fill="#181818" points="663.5,346.9219,653.5,350.9219,663.5,354.9219,659.5,350.9219" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="52" x="659.5" y="317.7231">&#35843;&#29992;&#29238;&#31867;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="102" x="659.5" y="332.856">buildController()</text><line style="stroke:#181818;stroke-width:1.0;" x1="652.5" x2="699.5" y1="380.0547" y2="380.0547"/><line style="stroke:#181818;stroke-width:1.0;" x1="699.5" x2="699.5" y1="380.0547" y2="393.0547"/><line style="stroke:#181818;stroke-width:1.0;" x1="658.5" x2="699.5" y1="393.0547" y2="393.0547"/><polygon fill="#181818" points="668.5,389.0547,658.5,393.0547,668.5,397.0547,664.5,393.0547" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="112" x="664.5" y="374.9888">obtainController()</text><polygon fill="#181818" points="765,423.1875,775,427.1875,765,431.1875,769,427.1875" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="657.5" x2="771" y1="427.1875" y2="427.1875"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="27" x="664.5" y="422.1216">new</text><rect fill="#E2E2F0" height="30.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="199" x="777" y="406.0547"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="185" x="784" y="426.0498">PipelineDraweeController</text><line style="stroke:#181818;stroke-width:1.0;" x1="657.5" x2="699.5" y1="513.8828" y2="513.8828"/><line style="stroke:#181818;stroke-width:1.0;" x1="699.5" x2="699.5" y1="513.8828" y2="526.8828"/><line style="stroke:#181818;stroke-width:1.0;" x1="658.5" x2="699.5" y1="526.8828" y2="526.8828"/><polygon fill="#181818" points="668.5,522.8828,658.5,526.8828,668.5,530.8828,664.5,526.8828" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="52" x="664.5" y="463.4185">&#35843;&#29992;&#29238;&#31867;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="189" x="664.5" y="478.5513">obtainDataSourceSupplier()&#65292;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="91" x="664.5" y="493.6841">&#36820;&#22238;&#19968;&#20010;&#20869;&#37096;&#31867;</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="174" x="664.5" y="508.8169">Supplier&lt;DataSource&lt;T&gt;&gt;</text><polygon fill="#181818" points="129,552.0156,119,556.0156,129,560.0156,125,556.0156" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" x1="123" x2="646.5" y1="556.0156" y2="556.0156"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="187" x="135" y="550.9497">&#36820;&#22238;PipelineDraweeController</text><!--SRC=[YyxNjLC8pimjo4brAKeiJqqDoqmjLz3MjbB8pCiiuSAG0QfM2iWiICt9p8CAE-VdbHJbv-Ia5ZcLPkQaf1O5bnOKv6Ic5Yaf91Ohm3X08nMi5D9JIpGqkU1YH1W6DWJALj3IGjABpTswkbOAB_PFUJfxNamU0OEvKb8Jaqioon9BKZ7CuOh66Ih5gIMUkOdfgQ51dbW31-PKiChGeaoGTmafyyz9GJYFW0QG6rviQ7u-PSNpZctFD-vE0ea3zS3ayIYDoGChHh4AXxRyf9B4p3nSAd766JYo45nWV04zc0SCJopMeBiDOgLBOabYS7vfKN8gBA8rDD_lwOd9WyJganqDJtQiUjhM-h9v1LWNJ9KDGgDDY9qTma9iyGXB8xYy0G00]--></g></svg>

<p>上图中的Supplier是<code>Supplier&lt;DataSource&lt;CloseableReference&lt;CloseableImage&gt;&gt;&gt;</code>是一个内部类,这个类就是DataSource提供者。如下：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//AbstractDraweeControllerBuilder.java</span></span><br><span class="line">  <span class="keyword">protected</span> Supplier&lt;DataSource&lt;IMAGE&gt;&gt; <span class="title function_">getDataSourceSupplierForRequest</span><span class="params">(</span></span><br><span class="line"><span class="params">      <span class="keyword">final</span> REQUEST imageRequest,</span></span><br><span class="line"><span class="params">      <span class="keyword">final</span> <span class="type">boolean</span> bitmapCacheOnly)</span> &#123;</span><br><span class="line">    <span class="keyword">final</span> <span class="type">Object</span> <span class="variable">callerContext</span> <span class="operator">=</span> getCallerContext();</span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">Supplier</span>&lt;DataSource&lt;IMAGE&gt;&gt;() &#123;</span><br><span class="line">      <span class="meta">@Override</span></span><br><span class="line">      <span class="keyword">public</span> DataSource&lt;IMAGE&gt; <span class="title function_">get</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> getDataSourceForRequest(imageRequest, callerContext, bitmapCacheOnly);</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="meta">@Override</span></span><br><span class="line">      <span class="keyword">public</span> String <span class="title function_">toString</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> Objects.toStringHelper(<span class="built_in">this</span>)</span><br><span class="line">            .add(<span class="string">&quot;request&quot;</span>, imageRequest.toString())</span><br><span class="line">            .toString();</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;;</span><br><span class="line">  &#125;</span><br><span class="line"><span class="comment">//PipelineDraweeControllerBuilder.java</span></span><br><span class="line">  <span class="keyword">protected</span> DataSource&lt;CloseableReference&lt;CloseableImage&gt;&gt; <span class="title function_">getDataSourceForRequest</span><span class="params">(</span></span><br><span class="line"><span class="params">      DraweeController controller,</span></span><br><span class="line"><span class="params">      String controllerId,</span></span><br><span class="line"><span class="params">      ImageRequest imageRequest,</span></span><br><span class="line"><span class="params">      Object callerContext,</span></span><br><span class="line"><span class="params">      AbstractDraweeControllerBuilder.CacheLevel cacheLevel)</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> mImagePipeline.fetchDecodedImage(</span><br><span class="line">        imageRequest,</span><br><span class="line">        callerContext,</span><br><span class="line">        convertCacheLevelToRequestLevel(cacheLevel),</span><br><span class="line">        getRequestListener(controller),</span><br><span class="line">        controllerId);</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<p>下面是与PipelineDraweeController构造相关的类图：</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="448px" preserveAspectRatio="none" style="width:830px;height:448px;background:#FFFFFF;" version="1.1" viewBox="0 0 830 448" width="830px" zoomAndPan="magnify"><defs/><g><!--class PipelineDraweeControllerBuilderSupplier--><g id="elem_PipelineDraweeControllerBuilderSupplier"><rect codeLine="1" fill="#F1F1F1" height="64.2969" id="PipelineDraweeControllerBuilderSupplier" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="327" x="88" y="268"/><ellipse cx="103" cy="284" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M105.3438,279.6719 C104.4063,279.2344 103.8125,279.0938 102.9375,279.0938 C100.3125,279.0938 98.3125,281.1719 98.3125,283.8906 L98.3125,285.0156 C98.3125,287.5938 100.4219,289.4844 103.3125,289.4844 C104.5313,289.4844 105.6875,289.1875 106.4375,288.6406 C107.0156,288.2344 107.3438,287.7813 107.3438,287.3906 C107.3438,286.9375 106.9531,286.5469 106.4844,286.5469 C106.2656,286.5469 106.0625,286.625 105.875,286.8125 C105.4219,287.2969 105.4219,287.2969 105.2344,287.3906 C104.8125,287.6563 104.125,287.7813 103.3594,287.7813 C101.3125,287.7813 100.0156,286.6875 100.0156,284.9844 L100.0156,283.8906 C100.0156,282.1094 101.2656,280.7969 103,280.7969 C103.5781,280.7969 104.1875,280.9531 104.6563,281.2031 C105.1406,281.4844 105.3125,281.7031 105.4063,282.1094 C105.4688,282.5156 105.5,282.6406 105.6406,282.7656 C105.7813,282.9063 106.0156,283.0156 106.2344,283.0156 C106.5,283.0156 106.7656,282.875 106.9375,282.6563 C107.0469,282.5 107.0781,282.3125 107.0781,281.8906 L107.0781,280.4688 C107.0781,280.0313 107.0625,279.9063 106.9688,279.75 C106.8125,279.4844 106.5313,279.3438 106.2344,279.3438 C105.9375,279.3438 105.7344,279.4375 105.5156,279.75 L105.3438,279.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="295" x="117" y="288.8467">PipelineDraweeControllerBuilderSupplier</text><line style="stroke:#181818;stroke-width:0.5;" x1="89" x2="414" y1="300" y2="300"/><line style="stroke:#181818;stroke-width:0.5;" x1="89" x2="414" y1="308" y2="308"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="274" x="94" y="324.9951">PipelineDraweeControllerBuilder get()</text></g><g id="elem_GMN3"><path d="M6,287.5 L6,312.6328 A0,0 0 0 0 6,312.6328 L53,312.6328 A0,0 0 0 0 53,312.6328 L53,305.5 L87.7921,300 L53,297.5 L53,297.5 L43,287.5 L6,287.5 A0,0 0 0 0 6,287.5 " fill="#FEFFDD" style="stroke:#181818;stroke-width:0.5;"/><path d="M43,287.5 L43,297.5 L53,297.5 L43,287.5 " fill="#FEFFDD" style="stroke:#181818;stroke-width:0.5;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="26" x="12" y="304.5669">&#21333;&#20363;</text></g><!--class ImagePipeline--><g id="elem_ImagePipeline"><rect fill="#F1F1F1" height="48" id="ImagePipeline" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="134" x="222.5" y="393"/><ellipse cx="237.5" cy="409" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M239.8438,404.6719 C238.9063,404.2344 238.3125,404.0938 237.4375,404.0938 C234.8125,404.0938 232.8125,406.1719 232.8125,408.8906 L232.8125,410.0156 C232.8125,412.5938 234.9219,414.4844 237.8125,414.4844 C239.0313,414.4844 240.1875,414.1875 240.9375,413.6406 C241.5156,413.2344 241.8438,412.7813 241.8438,412.3906 C241.8438,411.9375 241.4531,411.5469 240.9844,411.5469 C240.7656,411.5469 240.5625,411.625 240.375,411.8125 C239.9219,412.2969 239.9219,412.2969 239.7344,412.3906 C239.3125,412.6563 238.625,412.7813 237.8594,412.7813 C235.8125,412.7813 234.5156,411.6875 234.5156,409.9844 L234.5156,408.8906 C234.5156,407.1094 235.7656,405.7969 237.5,405.7969 C238.0781,405.7969 238.6875,405.9531 239.1563,406.2031 C239.6406,406.4844 239.8125,406.7031 239.9063,407.1094 C239.9688,407.5156 240,407.6406 240.1406,407.7656 C240.2813,407.9063 240.5156,408.0156 240.7344,408.0156 C241,408.0156 241.2656,407.875 241.4375,407.6563 C241.5469,407.5 241.5781,407.3125 241.5781,406.8906 L241.5781,405.4688 C241.5781,405.0313 241.5625,404.9063 241.4688,404.75 C241.3125,404.4844 241.0313,404.3438 240.7344,404.3438 C240.4375,404.3438 240.2344,404.4375 240.0156,404.75 L239.8438,404.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="102" x="251.5" y="413.8467">ImagePipeline</text><line style="stroke:#181818;stroke-width:0.5;" x1="223.5" x2="355.5" y1="425" y2="425"/><line style="stroke:#181818;stroke-width:0.5;" x1="223.5" x2="355.5" y1="433" y2="433"/></g><!--class PipelineDraweeControllerBuilder--><g id="elem_PipelineDraweeControllerBuilder"><rect fill="#F1F1F1" height="48" id="PipelineDraweeControllerBuilder" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="267" x="478" y="276"/><ellipse cx="493" cy="292" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M495.3438,287.6719 C494.4063,287.2344 493.8125,287.0938 492.9375,287.0938 C490.3125,287.0938 488.3125,289.1719 488.3125,291.8906 L488.3125,293.0156 C488.3125,295.5938 490.4219,297.4844 493.3125,297.4844 C494.5313,297.4844 495.6875,297.1875 496.4375,296.6406 C497.0156,296.2344 497.3438,295.7813 497.3438,295.3906 C497.3438,294.9375 496.9531,294.5469 496.4844,294.5469 C496.2656,294.5469 496.0625,294.625 495.875,294.8125 C495.4219,295.2969 495.4219,295.2969 495.2344,295.3906 C494.8125,295.6563 494.125,295.7813 493.3594,295.7813 C491.3125,295.7813 490.0156,294.6875 490.0156,292.9844 L490.0156,291.8906 C490.0156,290.1094 491.2656,288.7969 493,288.7969 C493.5781,288.7969 494.1875,288.9531 494.6563,289.2031 C495.1406,289.4844 495.3125,289.7031 495.4063,290.1094 C495.4688,290.5156 495.5,290.6406 495.6406,290.7656 C495.7813,290.9063 496.0156,291.0156 496.2344,291.0156 C496.5,291.0156 496.7656,290.875 496.9375,290.6563 C497.0469,290.5 497.0781,290.3125 497.0781,289.8906 L497.0781,288.4688 C497.0781,288.0313 497.0625,287.9063 496.9688,287.75 C496.8125,287.4844 496.5313,287.3438 496.2344,287.3438 C495.9375,287.3438 495.7344,287.4375 495.5156,287.75 L495.3438,287.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="235" x="507" y="296.8467">PipelineDraweeControllerBuilder</text><line style="stroke:#181818;stroke-width:0.5;" x1="479" x2="744" y1="308" y2="308"/><line style="stroke:#181818;stroke-width:0.5;" x1="479" x2="744" y1="316" y2="316"/></g><!--class PipelineDraweeControllerFactory--><g id="elem_PipelineDraweeControllerFactory"><rect fill="#F1F1F1" height="48" id="PipelineDraweeControllerFactory" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="271" x="407" y="393"/><ellipse cx="422" cy="409" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M424.3438,404.6719 C423.4063,404.2344 422.8125,404.0938 421.9375,404.0938 C419.3125,404.0938 417.3125,406.1719 417.3125,408.8906 L417.3125,410.0156 C417.3125,412.5938 419.4219,414.4844 422.3125,414.4844 C423.5313,414.4844 424.6875,414.1875 425.4375,413.6406 C426.0156,413.2344 426.3438,412.7813 426.3438,412.3906 C426.3438,411.9375 425.9531,411.5469 425.4844,411.5469 C425.2656,411.5469 425.0625,411.625 424.875,411.8125 C424.4219,412.2969 424.4219,412.2969 424.2344,412.3906 C423.8125,412.6563 423.125,412.7813 422.3594,412.7813 C420.3125,412.7813 419.0156,411.6875 419.0156,409.9844 L419.0156,408.8906 C419.0156,407.1094 420.2656,405.7969 422,405.7969 C422.5781,405.7969 423.1875,405.9531 423.6563,406.2031 C424.1406,406.4844 424.3125,406.7031 424.4063,407.1094 C424.4688,407.5156 424.5,407.6406 424.6406,407.7656 C424.7813,407.9063 425.0156,408.0156 425.2344,408.0156 C425.5,408.0156 425.7656,407.875 425.9375,407.6563 C426.0469,407.5 426.0781,407.3125 426.0781,406.8906 L426.0781,405.4688 C426.0781,405.0313 426.0625,404.9063 425.9688,404.75 C425.8125,404.4844 425.5313,404.3438 425.2344,404.3438 C424.9375,404.3438 424.7344,404.4375 424.5156,404.75 L424.3438,404.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="239" x="436" y="413.8467">PipelineDraweeControllerFactory</text><line style="stroke:#181818;stroke-width:0.5;" x1="408" x2="677" y1="425" y2="425"/><line style="stroke:#181818;stroke-width:0.5;" x1="408" x2="677" y1="433" y2="433"/></g><!--class AbstractDraweeControllerBuilder--><g id="elem_AbstractDraweeControllerBuilder"><rect codeLine="12" fill="#F1F1F1" height="64.2969" id="AbstractDraweeControllerBuilder" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="272" x="475.5" y="139"/><ellipse cx="492.3" cy="155" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M494.3781,156.8125 L494.7688,157.7969 L494.3781,157.7969 C493.925,157.7969 493.8156,157.8125 493.6594,157.9219 C493.4094,158.0781 493.2531,158.3594 493.2531,158.6563 C493.2531,158.9219 493.3938,159.1719 493.6125,159.3281 C493.7531,159.4531 493.9563,159.5 494.3781,159.5 L496.7375,159.5 C497.0969,159.5 497.3156,159.4688 497.4563,159.375 C497.7063,159.2344 497.8625,158.9375 497.8625,158.6563 C497.8625,158.375 497.7219,158.125 497.5031,157.9688 C497.3313,157.8281 497.175,157.7969 496.7063,157.7969 L493.3156,149.5938 L489.6438,149.5938 C489.1906,149.5938 489.0656,149.6094 488.9094,149.7031 C488.6594,149.875 488.5031,150.1563 488.5031,150.4375 C488.5031,150.7188 488.6438,150.9688 488.8625,151.1406 C489.0344,151.25 489.2063,151.2813 489.6438,151.2813 L490.7219,151.2813 L488.0813,157.7969 C487.6594,157.7969 487.5031,157.8125 487.3469,157.9219 C487.0969,158.0781 486.9406,158.3594 486.9406,158.6563 C486.9406,159.2188 487.3156,159.5 488.0656,159.5 L490.3313,159.5 C490.6906,159.5 490.9094,159.4688 491.0344,159.375 C491.3,159.2344 491.4406,158.9375 491.4406,158.6563 C491.4406,158.375 491.3156,158.125 491.0969,157.9531 C490.925,157.8281 490.7844,157.7969 490.3313,157.7969 L489.9406,157.7969 L490.3313,156.8125 L494.3781,156.8125 Z M493.675,155.1094 L491.0031,155.1094 L492.3469,151.8438 L493.675,155.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="236" x="506.7" y="159.8467">AbstractDraweeControllerBuilder</text><line style="stroke:#181818;stroke-width:0.5;" x1="476.5" x2="746.5" y1="171" y2="171"/><line style="stroke:#181818;stroke-width:0.5;" x1="476.5" x2="746.5" y1="179" y2="179"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="260" x="481.5" y="195.9951">getDataSourceSupplierForRequest()</text></g><!--class Supplier--><g id="elem_Supplier"><rect codeLine="11" fill="#F1F1F1" height="48" id="Supplier" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="416" x="403.5" y="10"/><ellipse cx="418.5" cy="26" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M420.8438,21.6719 C419.9063,21.2344 419.3125,21.0938 418.4375,21.0938 C415.8125,21.0938 413.8125,23.1719 413.8125,25.8906 L413.8125,27.0156 C413.8125,29.5938 415.9219,31.4844 418.8125,31.4844 C420.0313,31.4844 421.1875,31.1875 421.9375,30.6406 C422.5156,30.2344 422.8438,29.7813 422.8438,29.3906 C422.8438,28.9375 422.4531,28.5469 421.9844,28.5469 C421.7656,28.5469 421.5625,28.625 421.375,28.8125 C420.9219,29.2969 420.9219,29.2969 420.7344,29.3906 C420.3125,29.6563 419.625,29.7813 418.8594,29.7813 C416.8125,29.7813 415.5156,28.6875 415.5156,26.9844 L415.5156,25.8906 C415.5156,24.1094 416.7656,22.7969 418.5,22.7969 C419.0781,22.7969 419.6875,22.9531 420.1563,23.2031 C420.6406,23.4844 420.8125,23.7031 420.9063,24.1094 C420.9688,24.5156 421,24.6406 421.1406,24.7656 C421.2813,24.9063 421.5156,25.0156 421.7344,25.0156 C422,25.0156 422.2656,24.875 422.4375,24.6563 C422.5469,24.5 422.5781,24.3125 422.5781,23.8906 L422.5781,22.4688 C422.5781,22.0313 422.5625,21.9063 422.4688,21.75 C422.3125,21.4844 422.0313,21.3438 421.7344,21.3438 C421.4375,21.3438 421.2344,21.4375 421.0156,21.75 L420.8438,21.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="60" x="432.5" y="30.8467">Supplier</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="322" x="500.5" y="7"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="320" x="501.5" y="19.1387">DataSource&lt;CloseableReference&lt;CloseableImage&gt;&gt;</text><line style="stroke:#181818;stroke-width:0.5;" x1="404.5" x2="818.5" y1="42" y2="42"/><line style="stroke:#181818;stroke-width:0.5;" x1="404.5" x2="818.5" y1="50" y2="50"/></g><!--reverse link PipelineDraweeControllerBuilderSupplier to ImagePipeline--><g id="link_PipelineDraweeControllerBuilderSupplier_ImagePipeline"><path codeLine="5" d="M265.5484,343.5149 C271.8794,362.672 276.092,375.4234 281.862,392.8836 " fill="none" id="PipelineDraweeControllerBuilderSupplier-backto-ImagePipeline" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="261.783,332.121,259.8677,339.0731,265.5484,343.5149,267.4637,336.5628,261.783,332.121" style="stroke:#181818;stroke-width:1.0;"/></g><!--link PipelineDraweeControllerBuilderSupplier to PipelineDraweeControllerBuilder--><g id="link_PipelineDraweeControllerBuilderSupplier_PipelineDraweeControllerBuilder"><path codeLine="6" d="M415.172,300 C436.161,300 451.448,300 471.88,300 " fill="none" id="PipelineDraweeControllerBuilderSupplier-to-PipelineDraweeControllerBuilder" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="477.88,300,468.88,296,472.88,300,468.88,304,477.88,300" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="26" x="433.5" y="293.0669">&#26500;&#36896;</text></g><!--reverse link PipelineDraweeControllerBuilder to ImagePipeline--><g id="link_PipelineDraweeControllerBuilder_ImagePipeline"><path codeLine="7" d="M535.4251,328.1699 C479.4111,348.1744 410.154,372.9093 354.171,392.9033 " fill="none" id="PipelineDraweeControllerBuilder-backto-ImagePipeline" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="546.726,324.134,539.7302,322.385,535.4251,328.1699,542.4208,329.919,546.726,324.134" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link PipelineDraweeControllerBuilderSupplier to PipelineDraweeControllerFactory--><g id="link_PipelineDraweeControllerBuilderSupplier_PipelineDraweeControllerFactory"><path codeLine="8" d="M341.4092,336.5313 C389.8862,355.6884 439.824,375.4234 484.006,392.8836 " fill="none" id="PipelineDraweeControllerBuilderSupplier-backto-PipelineDraweeControllerFactory" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="330.249,332.121,334.359,338.0462,341.4092,336.5313,337.2992,330.6061,330.249,332.121" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link PipelineDraweeControllerBuilder to PipelineDraweeControllerFactory--><g id="link_PipelineDraweeControllerBuilder_PipelineDraweeControllerFactory"><path codeLine="9" d="M591.3631,334.5619 C579.3921,354.5138 568.408,372.8207 556.442,392.7626 " fill="none" id="PipelineDraweeControllerBuilder-backto-PipelineDraweeControllerFactory" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="597.537,324.272,591.0201,327.359,591.3631,334.5619,597.88,331.4749,597.537,324.272" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link AbstractDraweeControllerBuilder to PipelineDraweeControllerBuilder--><g id="link_AbstractDraweeControllerBuilder_PipelineDraweeControllerBuilder"><path codeLine="10" d="M611.5,225.039 C611.5,246.919 611.5,256.482 611.5,275.7 " fill="none" id="AbstractDraweeControllerBuilder-backto-PipelineDraweeControllerBuilder" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="611.5,207.039,605.5,225.039,617.5,225.039,611.5,207.039" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link Supplier to AbstractDraweeControllerBuilder--><g id="link_Supplier_AbstractDraweeControllerBuilder"><path codeLine="15" d="M668.3825,60.9716 C698.8505,77.6166 729.594,100.378 747.5,135 C758.936,157.111 773.393,191 748.5,191 " fill="none" id="Supplier-backto-AbstractDraweeControllerBuilder" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:7.0,7.0;"/><polygon fill="#181818" points="663.117,58.095,669.0975,65.9202,667.5049,60.4922,672.9329,58.8996,663.117,58.095" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="91" x="724.5" y="101.0669">&#26500;&#36896;&#20869;&#37096;&#31867;&#36820;&#22238;</text></g><!--SRC=[Iyv9B2vM2CWiICt9p4jrAKeiJqrrpiyhAShFoKajSYhDp4b9BGekBIZ8oKmjKgZcKW020geLqbDBD3IvQhdoyajI5N9IqqeKyjE8ji9AuMdlr2Vxkhc8rQ2bgwlWcPkOdWhJGBHENJk2Nh5IU3QlvMN30a9cKk0Aa4vSQjqIaqloYog9ifsG6Ov9nIL5G3OkCsngy1W2LSIL34ukCBVRk2IM90RdbnObfzeuv-GNfoOcvQG6fQQb5gNc8Gk10yREpeuh4Ue61OWvX9m4IMx0v8Im1sQrMtvHK6fXQMen9AaHCCdAYe0X2dgb1Nfs2aYf41BlJzjQNpQlUBvnzulzKvxEdWS0]--></g></svg>

<h2 id="三级缓存机制"><a href="#三级缓存机制" class="headerlink" title="三级缓存机制"></a>三级缓存机制</h2><p>Fresco采用了三级缓存机制，两级内存，一级磁盘。</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="471px" preserveAspectRatio="none" style="width:1107px;height:471px;background:#FFFFFF;" version="1.1" viewBox="0 0 1107 471" width="1107px" zoomAndPan="magnify"><defs/><g><!--cluster Bitmap????--><g id="cluster_Bitmap&#20869;&#23384;&#32531;&#23384;"><path d="M8.5,149 L128.5,149 A3.75,3.75 0 0 1 131,151.5 L138,171.2969 L421.5,171.2969 A2.5,2.5 0 0 1 424,173.7969 L424,461.5 A2.5,2.5 0 0 1 421.5,464 L8.5,464 A2.5,2.5 0 0 1 6,461.5 L6,151.5 A2.5,2.5 0 0 1 8.5,149 " fill="none" style="stroke:#000000;stroke-width:1.5;"/><line style="stroke:#000000;stroke-width:1.5;" x1="6" x2="138" y1="171.2969" y2="171.2969"/><text fill="#000000" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="119" x="10" y="163.9951">Bitmap&#20869;&#23384;&#32531;&#23384;</text></g><!--cluster ????????--><g id="cluster_&#21407;&#22987;&#22270;&#29255;&#20869;&#23384;&#32531;&#23384;"><path d="M450.5,149 L571.5,149 A3.75,3.75 0 0 1 574,151.5 L581,171.2969 L871.5,171.2969 A2.5,2.5 0 0 1 874,173.7969 L874,461.5 A2.5,2.5 0 0 1 871.5,464 L450.5,464 A2.5,2.5 0 0 1 448,461.5 L448,151.5 A2.5,2.5 0 0 1 450.5,149 " fill="none" style="stroke:#000000;stroke-width:1.5;"/><line style="stroke:#000000;stroke-width:1.5;" x1="448" x2="581" y1="171.2969" y2="171.2969"/><text fill="#000000" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="120" x="452" y="163.9951">&#21407;&#22987;&#22270;&#29255;&#20869;&#23384;&#32531;&#23384;</text></g><!--cluster ????--><g id="cluster_&#30913;&#30424;&#32531;&#23384;"><path d="M900.5,149 L961.5,149 A3.75,3.75 0 0 1 964,151.5 L971,171.2969 L1097.5,171.2969 A2.5,2.5 0 0 1 1100,173.7969 L1100,461.5 A2.5,2.5 0 0 1 1097.5,464 L900.5,464 A2.5,2.5 0 0 1 898,461.5 L898,151.5 A2.5,2.5 0 0 1 900.5,149 " fill="none" style="stroke:#000000;stroke-width:1.5;"/><line style="stroke:#000000;stroke-width:1.5;" x1="898" x2="971" y1="171.2969" y2="171.2969"/><text fill="#000000" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="60" x="902" y="163.9951">&#30913;&#30424;&#32531;&#23384;</text></g><!--class MemoryCache--><g id="elem_MemoryCache"><rect codeLine="9" fill="#F1F1F1" height="48" id="MemoryCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="300" x="87" y="184"/><ellipse cx="102" cy="200" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M102.9531,196.7813 L104.6719,196.7813 C105.0625,196.7813 105.25,196.75 105.375,196.6719 C105.6406,196.5156 105.7813,196.2344 105.7813,195.9375 C105.7813,195.6719 105.6719,195.4063 105.4375,195.2344 C105.2656,195.125 105.125,195.0938 104.6719,195.0938 L99.5313,195.0938 C99.0938,195.0938 98.9688,195.1094 98.8125,195.2031 C98.5625,195.3594 98.4063,195.6563 98.4063,195.9375 C98.4063,196.2188 98.5469,196.4688 98.7656,196.6406 C98.9219,196.75 99.1094,196.7813 99.5313,196.7813 L101.25,196.7813 L101.25,203.2969 L99.5313,203.2969 C99.0938,203.2969 98.9688,203.3125 98.8125,203.4219 C98.5625,203.5781 98.4063,203.8594 98.4063,204.1563 C98.4063,204.4063 98.5469,204.6719 98.7656,204.8281 C98.9219,204.9531 99.125,205 99.5313,205 L104.6719,205 C105.4219,205 105.7813,204.7188 105.7813,204.1563 C105.7813,203.875 105.6719,203.625 105.4375,203.4531 C105.2656,203.3281 105.125,203.2969 104.6719,203.2969 L102.9531,203.2969 L102.9531,196.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="103" x="116" y="204.8467">MemoryCache</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="163" x="227" y="181"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="161" x="228" y="193.1387">CacheKey, CloseableImage</text><line style="stroke:#181818;stroke-width:0.5;" x1="88" x2="386" y1="216" y2="216"/><line style="stroke:#181818;stroke-width:0.5;" x1="88" x2="386" y1="224" y2="224"/></g><!--class CountingMemoryCache--><g id="elem_CountingMemoryCache"><rect codeLine="10" fill="#F1F1F1" height="48" id="CountingMemoryCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="364" x="38" y="292"/><ellipse cx="53" cy="308" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M53.9531,304.7813 L55.6719,304.7813 C56.0625,304.7813 56.25,304.75 56.375,304.6719 C56.6406,304.5156 56.7813,304.2344 56.7813,303.9375 C56.7813,303.6719 56.6719,303.4063 56.4375,303.2344 C56.2656,303.125 56.125,303.0938 55.6719,303.0938 L50.5313,303.0938 C50.0938,303.0938 49.9688,303.1094 49.8125,303.2031 C49.5625,303.3594 49.4063,303.6563 49.4063,303.9375 C49.4063,304.2188 49.5469,304.4688 49.7656,304.6406 C49.9219,304.75 50.1094,304.7813 50.5313,304.7813 L52.25,304.7813 L52.25,311.2969 L50.5313,311.2969 C50.0938,311.2969 49.9688,311.3125 49.8125,311.4219 C49.5625,311.5781 49.4063,311.8594 49.4063,312.1563 C49.4063,312.4063 49.5469,312.6719 49.7656,312.8281 C49.9219,312.9531 50.125,313 50.5313,313 L55.6719,313 C56.4219,313 56.7813,312.7188 56.7813,312.1563 C56.7813,311.875 56.6719,311.625 56.4375,311.4531 C56.2656,311.3281 56.125,311.2969 55.6719,311.2969 L53.9531,311.2969 L53.9531,304.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="167" x="67" y="312.8467">CountingMemoryCache</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="163" x="242" y="289"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="161" x="243" y="301.1387">CacheKey, CloseableImage</text><line style="stroke:#181818;stroke-width:0.5;" x1="39" x2="401" y1="324" y2="324"/><line style="stroke:#181818;stroke-width:0.5;" x1="39" x2="401" y1="332" y2="332"/></g><!--class LruCountingMemoryCache--><g id="elem_LruCountingMemoryCache"><rect codeLine="11" fill="#F1F1F1" height="48" id="LruCountingMemoryCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="386" x="22" y="400"/><ellipse cx="37" cy="416" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M39.3438,411.6719 C38.4063,411.2344 37.8125,411.0938 36.9375,411.0938 C34.3125,411.0938 32.3125,413.1719 32.3125,415.8906 L32.3125,417.0156 C32.3125,419.5938 34.4219,421.4844 37.3125,421.4844 C38.5313,421.4844 39.6875,421.1875 40.4375,420.6406 C41.0156,420.2344 41.3438,419.7813 41.3438,419.3906 C41.3438,418.9375 40.9531,418.5469 40.4844,418.5469 C40.2656,418.5469 40.0625,418.625 39.875,418.8125 C39.4219,419.2969 39.4219,419.2969 39.2344,419.3906 C38.8125,419.6563 38.125,419.7813 37.3594,419.7813 C35.3125,419.7813 34.0156,418.6875 34.0156,416.9844 L34.0156,415.8906 C34.0156,414.1094 35.2656,412.7969 37,412.7969 C37.5781,412.7969 38.1875,412.9531 38.6563,413.2031 C39.1406,413.4844 39.3125,413.7031 39.4063,414.1094 C39.4688,414.5156 39.5,414.6406 39.6406,414.7656 C39.7813,414.9063 40.0156,415.0156 40.2344,415.0156 C40.5,415.0156 40.7656,414.875 40.9375,414.6563 C41.0469,414.5 41.0781,414.3125 41.0781,413.8906 L41.0781,412.4688 C41.0781,412.0313 41.0625,411.9063 40.9688,411.75 C40.8125,411.4844 40.5313,411.3438 40.2344,411.3438 C39.9375,411.3438 39.7344,411.4375 39.5156,411.75 L39.3438,411.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="189" x="51" y="420.8467">LruCountingMemoryCache</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="163" x="248" y="397"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="161" x="249" y="409.1387">CacheKey, CloseableImage</text><line style="stroke:#181818;stroke-width:0.5;" x1="23" x2="407" y1="432" y2="432"/><line style="stroke:#181818;stroke-width:0.5;" x1="23" x2="407" y1="440" y2="440"/></g><!--class MemoryCache2--><g id="elem_MemoryCache2"><rect codeLine="15" fill="#F1F1F1" height="48" id="MemoryCache2" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="308" x="533" y="184"/><ellipse cx="548" cy="200" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M548.9531,196.7813 L550.6719,196.7813 C551.0625,196.7813 551.25,196.75 551.375,196.6719 C551.6406,196.5156 551.7813,196.2344 551.7813,195.9375 C551.7813,195.6719 551.6719,195.4063 551.4375,195.2344 C551.2656,195.125 551.125,195.0938 550.6719,195.0938 L545.5313,195.0938 C545.0938,195.0938 544.9688,195.1094 544.8125,195.2031 C544.5625,195.3594 544.4063,195.6563 544.4063,195.9375 C544.4063,196.2188 544.5469,196.4688 544.7656,196.6406 C544.9219,196.75 545.1094,196.7813 545.5313,196.7813 L547.25,196.7813 L547.25,203.2969 L545.5313,203.2969 C545.0938,203.2969 544.9688,203.3125 544.8125,203.4219 C544.5625,203.5781 544.4063,203.8594 544.4063,204.1563 C544.4063,204.4063 544.5469,204.6719 544.7656,204.8281 C544.9219,204.9531 545.125,205 545.5313,205 L550.6719,205 C551.4219,205 551.7813,204.7188 551.7813,204.1563 C551.7813,203.875 551.6719,203.625 551.4375,203.4531 C551.2656,203.3281 551.125,203.2969 550.6719,203.2969 L548.9531,203.2969 L548.9531,196.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="103" x="562" y="204.8467">MemoryCache</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="171" x="673" y="181"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="169" x="674" y="193.1387">CacheKey, PooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="534" x2="840" y1="216" y2="216"/><line style="stroke:#181818;stroke-width:0.5;" x1="534" x2="840" y1="224" y2="224"/></g><!--class CountingMemoryCache2--><g id="elem_CountingMemoryCache2"><rect codeLine="16" fill="#F1F1F1" height="48" id="CountingMemoryCache2" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="372" x="480" y="292"/><ellipse cx="495" cy="308" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M495.9531,304.7813 L497.6719,304.7813 C498.0625,304.7813 498.25,304.75 498.375,304.6719 C498.6406,304.5156 498.7813,304.2344 498.7813,303.9375 C498.7813,303.6719 498.6719,303.4063 498.4375,303.2344 C498.2656,303.125 498.125,303.0938 497.6719,303.0938 L492.5313,303.0938 C492.0938,303.0938 491.9688,303.1094 491.8125,303.2031 C491.5625,303.3594 491.4063,303.6563 491.4063,303.9375 C491.4063,304.2188 491.5469,304.4688 491.7656,304.6406 C491.9219,304.75 492.1094,304.7813 492.5313,304.7813 L494.25,304.7813 L494.25,311.2969 L492.5313,311.2969 C492.0938,311.2969 491.9688,311.3125 491.8125,311.4219 C491.5625,311.5781 491.4063,311.8594 491.4063,312.1563 C491.4063,312.4063 491.5469,312.6719 491.7656,312.8281 C491.9219,312.9531 492.125,313 492.5313,313 L497.6719,313 C498.4219,313 498.7813,312.7188 498.7813,312.1563 C498.7813,311.875 498.6719,311.625 498.4375,311.4531 C498.2656,311.3281 498.125,311.2969 497.6719,311.2969 L495.9531,311.2969 L495.9531,304.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="167" x="509" y="312.8467">CountingMemoryCache</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="171" x="684" y="289"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="169" x="685" y="301.1387">CacheKey, PooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="481" x2="851" y1="324" y2="324"/><line style="stroke:#181818;stroke-width:0.5;" x1="481" x2="851" y1="332" y2="332"/></g><!--class LruCountingMemoryCache2--><g id="elem_LruCountingMemoryCache2"><rect codeLine="17" fill="#F1F1F1" height="48" id="LruCountingMemoryCache2" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="394" x="464" y="400"/><ellipse cx="479" cy="416" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M481.3438,411.6719 C480.4063,411.2344 479.8125,411.0938 478.9375,411.0938 C476.3125,411.0938 474.3125,413.1719 474.3125,415.8906 L474.3125,417.0156 C474.3125,419.5938 476.4219,421.4844 479.3125,421.4844 C480.5313,421.4844 481.6875,421.1875 482.4375,420.6406 C483.0156,420.2344 483.3438,419.7813 483.3438,419.3906 C483.3438,418.9375 482.9531,418.5469 482.4844,418.5469 C482.2656,418.5469 482.0625,418.625 481.875,418.8125 C481.4219,419.2969 481.4219,419.2969 481.2344,419.3906 C480.8125,419.6563 480.125,419.7813 479.3594,419.7813 C477.3125,419.7813 476.0156,418.6875 476.0156,416.9844 L476.0156,415.8906 C476.0156,414.1094 477.2656,412.7969 479,412.7969 C479.5781,412.7969 480.1875,412.9531 480.6563,413.2031 C481.1406,413.4844 481.3125,413.7031 481.4063,414.1094 C481.4688,414.5156 481.5,414.6406 481.6406,414.7656 C481.7813,414.9063 482.0156,415.0156 482.2344,415.0156 C482.5,415.0156 482.7656,414.875 482.9375,414.6563 C483.0469,414.5 483.0781,414.3125 483.0781,413.8906 L483.0781,412.4688 C483.0781,412.0313 483.0625,411.9063 482.9688,411.75 C482.8125,411.4844 482.5313,411.3438 482.2344,411.3438 C481.9375,411.3438 481.7344,411.4375 481.5156,411.75 L481.3438,411.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="189" x="493" y="420.8467">LruCountingMemoryCache</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="171" x="690" y="397"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="169" x="691" y="409.1387">CacheKey, PooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="465" x2="857" y1="432" y2="432"/><line style="stroke:#181818;stroke-width:0.5;" x1="465" x2="857" y1="440" y2="440"/></g><!--class BufferedDiskCache--><g id="elem_BufferedDiskCache"><rect fill="#F1F1F1" height="48" id="BufferedDiskCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="170" x="914" y="184"/><ellipse cx="929" cy="200" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M931.3438,195.6719 C930.4063,195.2344 929.8125,195.0938 928.9375,195.0938 C926.3125,195.0938 924.3125,197.1719 924.3125,199.8906 L924.3125,201.0156 C924.3125,203.5938 926.4219,205.4844 929.3125,205.4844 C930.5313,205.4844 931.6875,205.1875 932.4375,204.6406 C933.0156,204.2344 933.3438,203.7813 933.3438,203.3906 C933.3438,202.9375 932.9531,202.5469 932.4844,202.5469 C932.2656,202.5469 932.0625,202.625 931.875,202.8125 C931.4219,203.2969 931.4219,203.2969 931.2344,203.3906 C930.8125,203.6563 930.125,203.7813 929.3594,203.7813 C927.3125,203.7813 926.0156,202.6875 926.0156,200.9844 L926.0156,199.8906 C926.0156,198.1094 927.2656,196.7969 929,196.7969 C929.5781,196.7969 930.1875,196.9531 930.6563,197.2031 C931.1406,197.4844 931.3125,197.7031 931.4063,198.1094 C931.4688,198.5156 931.5,198.6406 931.6406,198.7656 C931.7813,198.9063 932.0156,199.0156 932.2344,199.0156 C932.5,199.0156 932.7656,198.875 932.9375,198.6563 C933.0469,198.5 933.0781,198.3125 933.0781,197.8906 L933.0781,196.4688 C933.0781,196.0313 933.0625,195.9063 932.9688,195.75 C932.8125,195.4844 932.5313,195.3438 932.2344,195.3438 C931.9375,195.3438 931.7344,195.4375 931.5156,195.75 L931.3438,195.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="138" x="943" y="204.8467">BufferedDiskCache</text><line style="stroke:#181818;stroke-width:0.5;" x1="915" x2="1083" y1="216" y2="216"/><line style="stroke:#181818;stroke-width:0.5;" x1="915" x2="1083" y1="224" y2="224"/></g><!--class FileCache--><g id="elem_FileCache"><rect codeLine="28" fill="#F1F1F1" height="48" id="FileCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="102" x="948" y="292"/><ellipse cx="963" cy="308" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M963.9531,304.7813 L965.6719,304.7813 C966.0625,304.7813 966.25,304.75 966.375,304.6719 C966.6406,304.5156 966.7813,304.2344 966.7813,303.9375 C966.7813,303.6719 966.6719,303.4063 966.4375,303.2344 C966.2656,303.125 966.125,303.0938 965.6719,303.0938 L960.5313,303.0938 C960.0938,303.0938 959.9688,303.1094 959.8125,303.2031 C959.5625,303.3594 959.4063,303.6563 959.4063,303.9375 C959.4063,304.2188 959.5469,304.4688 959.7656,304.6406 C959.9219,304.75 960.1094,304.7813 960.5313,304.7813 L962.25,304.7813 L962.25,311.2969 L960.5313,311.2969 C960.0938,311.2969 959.9688,311.3125 959.8125,311.4219 C959.5625,311.5781 959.4063,311.8594 959.4063,312.1563 C959.4063,312.4063 959.5469,312.6719 959.7656,312.8281 C959.9219,312.9531 960.125,313 960.5313,313 L965.6719,313 C966.4219,313 966.7813,312.7188 966.7813,312.1563 C966.7813,311.875 966.6719,311.625 966.4375,311.4531 C966.2656,311.3281 966.125,311.2969 965.6719,311.2969 L963.9531,311.2969 L963.9531,304.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="70" x="977" y="312.8467">FileCache</text><line style="stroke:#181818;stroke-width:0.5;" x1="949" x2="1049" y1="324" y2="324"/><line style="stroke:#181818;stroke-width:0.5;" x1="949" x2="1049" y1="332" y2="332"/></g><!--class DiskStorageCache--><g id="elem_DiskStorageCache"><rect fill="#F1F1F1" height="48" id="DiskStorageCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="164" x="917" y="400"/><ellipse cx="932" cy="416" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M934.3438,411.6719 C933.4063,411.2344 932.8125,411.0938 931.9375,411.0938 C929.3125,411.0938 927.3125,413.1719 927.3125,415.8906 L927.3125,417.0156 C927.3125,419.5938 929.4219,421.4844 932.3125,421.4844 C933.5313,421.4844 934.6875,421.1875 935.4375,420.6406 C936.0156,420.2344 936.3438,419.7813 936.3438,419.3906 C936.3438,418.9375 935.9531,418.5469 935.4844,418.5469 C935.2656,418.5469 935.0625,418.625 934.875,418.8125 C934.4219,419.2969 934.4219,419.2969 934.2344,419.3906 C933.8125,419.6563 933.125,419.7813 932.3594,419.7813 C930.3125,419.7813 929.0156,418.6875 929.0156,416.9844 L929.0156,415.8906 C929.0156,414.1094 930.2656,412.7969 932,412.7969 C932.5781,412.7969 933.1875,412.9531 933.6563,413.2031 C934.1406,413.4844 934.3125,413.7031 934.4063,414.1094 C934.4688,414.5156 934.5,414.6406 934.6406,414.7656 C934.7813,414.9063 935.0156,415.0156 935.2344,415.0156 C935.5,415.0156 935.7656,414.875 935.9375,414.6563 C936.0469,414.5 936.0781,414.3125 936.0781,413.8906 L936.0781,412.4688 C936.0781,412.0313 936.0625,411.9063 935.9688,411.75 C935.8125,411.4844 935.5313,411.3438 935.2344,411.3438 C934.9375,411.3438 934.7344,411.4375 934.5156,411.75 L934.3438,411.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="132" x="946" y="420.8467">DiskStorageCache</text><line style="stroke:#181818;stroke-width:0.5;" x1="918" x2="1080" y1="432" y2="432"/><line style="stroke:#181818;stroke-width:0.5;" x1="918" x2="1080" y1="440" y2="440"/></g><!--class ImagePipeline--><g id="elem_ImagePipeline"><rect codeLine="1" fill="#F1F1F1" height="113.1875" id="ImagePipeline" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="247" x="718.5" y="7"/><ellipse cx="786.75" cy="23" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M789.0938,18.6719 C788.1563,18.2344 787.5625,18.0938 786.6875,18.0938 C784.0625,18.0938 782.0625,20.1719 782.0625,22.8906 L782.0625,24.0156 C782.0625,26.5938 784.1719,28.4844 787.0625,28.4844 C788.2813,28.4844 789.4375,28.1875 790.1875,27.6406 C790.7656,27.2344 791.0938,26.7813 791.0938,26.3906 C791.0938,25.9375 790.7031,25.5469 790.2344,25.5469 C790.0156,25.5469 789.8125,25.625 789.625,25.8125 C789.1719,26.2969 789.1719,26.2969 788.9844,26.3906 C788.5625,26.6563 787.875,26.7813 787.1094,26.7813 C785.0625,26.7813 783.7656,25.6875 783.7656,23.9844 L783.7656,22.8906 C783.7656,21.1094 785.0156,19.7969 786.75,19.7969 C787.3281,19.7969 787.9375,19.9531 788.4063,20.2031 C788.8906,20.4844 789.0625,20.7031 789.1563,21.1094 C789.2188,21.5156 789.25,21.6406 789.3906,21.7656 C789.5313,21.9063 789.7656,22.0156 789.9844,22.0156 C790.25,22.0156 790.5156,21.875 790.6875,21.6563 C790.7969,21.5 790.8281,21.3125 790.8281,20.8906 L790.8281,19.4688 C790.8281,19.0313 790.8125,18.9063 790.7188,18.75 C790.5625,18.4844 790.2813,18.3438 789.9844,18.3438 C789.6875,18.3438 789.4844,18.4375 789.2656,18.75 L789.0938,18.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="102" x="807.25" y="27.8467">ImagePipeline</text><line style="stroke:#181818;stroke-width:0.5;" x1="719.5" x2="964.5" y1="39" y2="39"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="169" x="724.5" y="55.9951">mBitmapMemoryCache</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="178" x="724.5" y="72.292">mEncodedMemoryCache</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="185" x="724.5" y="88.5889">mMainBufferedDiskCache</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="235" x="724.5" y="104.8857">mSmallImageBufferedDiskCache</text><line style="stroke:#181818;stroke-width:0.5;" x1="719.5" x2="964.5" y1="112.1875" y2="112.1875"/></g><!--reverse link MemoryCache2 to CountingMemoryCache2--><g id="link_MemoryCache2_CountingMemoryCache2"><path codeLine="19" d="M678.9452,249.6569 C675.4472,267.3149 674.134,273.941 670.62,291.678 " fill="none" id="MemoryCache2-backto-CountingMemoryCache2" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="682.443,232,673.0596,248.491,684.8308,250.8228,682.443,232" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CountingMemoryCache2 to LruCountingMemoryCache2--><g id="link_CountingMemoryCache2_LruCountingMemoryCache2"><path codeLine="20" d="M664.0668,357.98 C663.2338,375.638 662.937,381.9408 662.1,399.6784 " fill="none" id="CountingMemoryCache2-backto-LruCountingMemoryCache2" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="664.915,340,658.0735,357.6973,670.0601,358.2627,664.915,340" style="stroke:#181818;stroke-width:1.0;"/></g><!--link ImagePipeline to MemoryCache--><g id="link_ImagePipeline_MemoryCache"><path codeLine="21" d="M718,51.5 C547.961,51.5 365.0855,137.7529 283.6265,181.0709 " fill="none" id="ImagePipeline-to-MemoryCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="278.329,183.888,288.1534,183.194,282.7436,181.5404,284.3972,176.1306,278.329,183.888" style="stroke:#181818;stroke-width:1.0;"/></g><!--link ImagePipeline to MemoryCache2--><g id="link_ImagePipeline_MemoryCache2"><path codeLine="22" d="M718,67.5 C670.862,67.5 675.7047,138.4119 681.8067,178.0339 " fill="none" id="ImagePipeline-to-MemoryCache2" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="682.72,183.964,685.3035,174.46,681.9589,179.0223,677.3967,175.6777,682.72,183.964" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link MemoryCache to CountingMemoryCache--><g id="link_MemoryCache_CountingMemoryCache"><path codeLine="23" d="M230.4606,249.7729 C227.6286,267.4309 226.585,273.941 223.74,291.678 " fill="none" id="MemoryCache-backto-CountingMemoryCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="233.311,232,224.5363,248.8227,236.3849,250.723,233.311,232" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CountingMemoryCache to LruCountingMemoryCache--><g id="link_CountingMemoryCache_LruCountingMemoryCache"><path codeLine="24" d="M218.0668,357.98 C217.2338,375.638 216.937,381.9408 216.1,399.6784 " fill="none" id="CountingMemoryCache-backto-LruCountingMemoryCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="218.915,340,212.0735,357.6973,224.0601,358.2627,218.915,340" style="stroke:#181818;stroke-width:1.0;"/></g><!--link ImagePipeline to BufferedDiskCache--><g id="link_ImagePipeline_BufferedDiskCache"><path codeLine="26" d="M967,83.5 C1007.98,83.5 1007.1067,142.0332 1003.1067,177.8082 " fill="none" id="ImagePipeline-to-BufferedDiskCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="1002.44,183.771,1007.4153,175.2712,1002.9956,178.802,999.4648,174.3823,1002.44,183.771" style="stroke:#181818;stroke-width:1.0;"/></g><!--link ImagePipeline to BufferedDiskCache--><g id="link_ImagePipeline_BufferedDiskCache"><path codeLine="27" d="M967,99.5 C1001.95,99.5 1004.0218,146.3655 1001.9018,177.9525 " fill="none" id="ImagePipeline-to-BufferedDiskCache-1" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="1001.5,183.939,1006.0937,175.2271,1001.8348,178.9502,998.1117,174.6913,1001.5,183.939" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link FileCache to DiskStorageCache--><g id="link_FileCache_DiskStorageCache"><path codeLine="29" d="M999,358 C999,375.658 999,381.9408 999,399.6784 " fill="none" id="FileCache-backto-DiskStorageCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="999,340,993,358,1005,358,999,340" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BufferedDiskCache to FileCache--><g id="link_BufferedDiskCache_FileCache"><path codeLine="30" d="M999,244 C999,261.658 999,273.941 999,291.678 " fill="none" id="BufferedDiskCache-backto-FileCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="999,232,995,238,999,244,1003,238,999,232" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[bLEzJiCm4Dxp55P6H9QCLPKX0IG4bIhr2OnpALOTEyhF44471a08YOK5gGC30nDlW7YRAA-1cz36IPm06QpuVDztttUw8mmd2JeDyHBcD096EQ0h0yalT6aQucW6eOXp3vDBgCF7d0WV_5vyXYbtio206FmZcgoKfqM86Qjgz1FMXX5Xif9loAmh5dUtnSTB-VaiJxCIGtaASO098ANgj3hF83z47XC9u0i6LGsdXV14nbFAbtz5ageXvt7sFw1getXwBTuVYyrN-N0_PiRKKy-5OE2xUVhJBST4E56TsssMSQ5wDWt6tfitVtMl9zN3RDaRzOgcrvQb5w0Brkb3rAt1dKpwCuiior5xrqFqnxaBiLNvW-fruiUqD-DIljsKczQ8T3LgLwkIgLkuBdfa-mOvcl4weGnsqVr_RMmBMAGYbioxZ7w50vdOSAo_0G00]--></g></svg>

<h3 id="内存缓存池"><a href="#内存缓存池" class="headerlink" title="内存缓存池"></a>内存缓存池</h3><p>Fresco的第一级和第二级内存缓存都是采用<code>LruCountingMemoryCache</code>来进行内存管理。</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="344px" preserveAspectRatio="none" style="width:545px;height:344px;background:#FFFFFF;" version="1.1" viewBox="0 0 545 344" width="545px" zoomAndPan="magnify"><defs/><g><!--class LruCountingMemoryCache--><g id="elem_LruCountingMemoryCache"><rect codeLine="1" fill="#F1F1F1" height="80.5938" id="LruCountingMemoryCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="397" x="71.5" y="7"/><ellipse cx="171.25" cy="23" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M173.5938,18.6719 C172.6563,18.2344 172.0625,18.0938 171.1875,18.0938 C168.5625,18.0938 166.5625,20.1719 166.5625,22.8906 L166.5625,24.0156 C166.5625,26.5938 168.6719,28.4844 171.5625,28.4844 C172.7813,28.4844 173.9375,28.1875 174.6875,27.6406 C175.2656,27.2344 175.5938,26.7813 175.5938,26.3906 C175.5938,25.9375 175.2031,25.5469 174.7344,25.5469 C174.5156,25.5469 174.3125,25.625 174.125,25.8125 C173.6719,26.2969 173.6719,26.2969 173.4844,26.3906 C173.0625,26.6563 172.375,26.7813 171.6094,26.7813 C169.5625,26.7813 168.2656,25.6875 168.2656,23.9844 L168.2656,22.8906 C168.2656,21.1094 169.5156,19.7969 171.25,19.7969 C171.8281,19.7969 172.4375,19.9531 172.9063,20.2031 C173.3906,20.4844 173.5625,20.7031 173.6563,21.1094 C173.7188,21.5156 173.75,21.6406 173.8906,21.7656 C174.0313,21.9063 174.2656,22.0156 174.4844,22.0156 C174.75,22.0156 175.0156,21.875 175.1875,21.6563 C175.2969,21.5 175.3281,21.3125 175.3281,20.8906 L175.3281,19.4688 C175.3281,19.0313 175.3125,18.9063 175.2188,18.75 C175.0625,18.4844 174.7813,18.3438 174.4844,18.3438 C174.1875,18.3438 173.9844,18.4375 173.7656,18.75 L173.5938,18.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="189" x="191.75" y="27.8467">LruCountingMemoryCache</text><line style="stroke:#181818;stroke-width:0.5;" x1="72.5" x2="467.5" y1="39" y2="39"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="385" x="77.5" y="55.9951">CountingLruMap&lt;K, Entry&lt;K, V&gt;&gt; mExclusiveEntries;</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="373" x="77.5" y="72.292">CountingLruMap&lt;K, Entry&lt;K, V&gt;&gt; mCachedEntries;</text><line style="stroke:#181818;stroke-width:0.5;" x1="72.5" x2="467.5" y1="79.5938" y2="79.5938"/></g><!--class clm1--><g id="elem_clm1"><rect codeLine="5" fill="#F1F1F1" height="80.5938" id="clm1" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="246" x="7" y="148"/><ellipse cx="22" cy="164" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M24.3438,159.6719 C23.4063,159.2344 22.8125,159.0938 21.9375,159.0938 C19.3125,159.0938 17.3125,161.1719 17.3125,163.8906 L17.3125,165.0156 C17.3125,167.5938 19.4219,169.4844 22.3125,169.4844 C23.5313,169.4844 24.6875,169.1875 25.4375,168.6406 C26.0156,168.2344 26.3438,167.7813 26.3438,167.3906 C26.3438,166.9375 25.9531,166.5469 25.4844,166.5469 C25.2656,166.5469 25.0625,166.625 24.875,166.8125 C24.4219,167.2969 24.4219,167.2969 24.2344,167.3906 C23.8125,167.6563 23.125,167.7813 22.3594,167.7813 C20.3125,167.7813 19.0156,166.6875 19.0156,164.9844 L19.0156,163.8906 C19.0156,162.1094 20.2656,160.7969 22,160.7969 C22.5781,160.7969 23.1875,160.9531 23.6563,161.2031 C24.1406,161.4844 24.3125,161.7031 24.4063,162.1094 C24.4688,162.5156 24.5,162.6406 24.6406,162.7656 C24.7813,162.9063 25.0156,163.0156 25.2344,163.0156 C25.5,163.0156 25.7656,162.875 25.9375,162.6563 C26.0469,162.5 26.0781,162.3125 26.0781,161.8906 L26.0781,160.4688 C26.0781,160.0313 26.0625,159.9063 25.9688,159.75 C25.8125,159.4844 25.5313,159.3438 25.2344,159.3438 C24.9375,159.3438 24.7344,159.4375 24.5156,159.75 L24.3438,159.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="117" x="36" y="168.8467">CountingLruMap</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="95" x="161" y="145"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="93" x="162" y="157.1387">K, Entry&lt;K, V&gt;</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="252" y1="180" y2="180"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="215" x="13" y="196.9951">LinkedHashMap&lt;K, V&gt; mMap;</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="155" x="13" y="213.292">int mSizeInBytes = 0;</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="252" y1="220.5938" y2="220.5938"/></g><!--class clm2--><g id="elem_clm2"><rect codeLine="9" fill="#F1F1F1" height="80.5938" id="clm2" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="246" x="288" y="148"/><ellipse cx="303" cy="164" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M305.3438,159.6719 C304.4063,159.2344 303.8125,159.0938 302.9375,159.0938 C300.3125,159.0938 298.3125,161.1719 298.3125,163.8906 L298.3125,165.0156 C298.3125,167.5938 300.4219,169.4844 303.3125,169.4844 C304.5313,169.4844 305.6875,169.1875 306.4375,168.6406 C307.0156,168.2344 307.3438,167.7813 307.3438,167.3906 C307.3438,166.9375 306.9531,166.5469 306.4844,166.5469 C306.2656,166.5469 306.0625,166.625 305.875,166.8125 C305.4219,167.2969 305.4219,167.2969 305.2344,167.3906 C304.8125,167.6563 304.125,167.7813 303.3594,167.7813 C301.3125,167.7813 300.0156,166.6875 300.0156,164.9844 L300.0156,163.8906 C300.0156,162.1094 301.2656,160.7969 303,160.7969 C303.5781,160.7969 304.1875,160.9531 304.6563,161.2031 C305.1406,161.4844 305.3125,161.7031 305.4063,162.1094 C305.4688,162.5156 305.5,162.6406 305.6406,162.7656 C305.7813,162.9063 306.0156,163.0156 306.2344,163.0156 C306.5,163.0156 306.7656,162.875 306.9375,162.6563 C307.0469,162.5 307.0781,162.3125 307.0781,161.8906 L307.0781,160.4688 C307.0781,160.0313 307.0625,159.9063 306.9688,159.75 C306.8125,159.4844 306.5313,159.3438 306.2344,159.3438 C305.9375,159.3438 305.7344,159.4375 305.5156,159.75 L305.3438,159.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="117" x="317" y="168.8467">CountingLruMap</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="95" x="442" y="145"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="93" x="443" y="157.1387">K, Entry&lt;K, V&gt;</text><line style="stroke:#181818;stroke-width:0.5;" x1="289" x2="533" y1="180" y2="180"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="215" x="294" y="196.9951">LinkedHashMap&lt;K, V&gt; mMap;</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="155" x="294" y="213.292">int mSizeInBytes = 0;</text><line style="stroke:#181818;stroke-width:0.5;" x1="289" x2="533" y1="220.5938" y2="220.5938"/></g><!--class lhm1--><g id="elem_lhm1"><rect codeLine="15" fill="#F1F1F1" height="48" id="lhm1" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="172" x="44" y="289"/><ellipse cx="59" cy="305" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M61.3438,300.6719 C60.4063,300.2344 59.8125,300.0938 58.9375,300.0938 C56.3125,300.0938 54.3125,302.1719 54.3125,304.8906 L54.3125,306.0156 C54.3125,308.5938 56.4219,310.4844 59.3125,310.4844 C60.5313,310.4844 61.6875,310.1875 62.4375,309.6406 C63.0156,309.2344 63.3438,308.7813 63.3438,308.3906 C63.3438,307.9375 62.9531,307.5469 62.4844,307.5469 C62.2656,307.5469 62.0625,307.625 61.875,307.8125 C61.4219,308.2969 61.4219,308.2969 61.2344,308.3906 C60.8125,308.6563 60.125,308.7813 59.3594,308.7813 C57.3125,308.7813 56.0156,307.6875 56.0156,305.9844 L56.0156,304.8906 C56.0156,303.1094 57.2656,301.7969 59,301.7969 C59.5781,301.7969 60.1875,301.9531 60.6563,302.2031 C61.1406,302.4844 61.3125,302.7031 61.4063,303.1094 C61.4688,303.5156 61.5,303.6406 61.6406,303.7656 C61.7813,303.9063 62.0156,304.0156 62.2344,304.0156 C62.5,304.0156 62.7656,303.875 62.9375,303.6563 C63.0469,303.5 63.0781,303.3125 63.0781,302.8906 L63.0781,301.4688 C63.0781,301.0313 63.0625,300.9063 62.9688,300.75 C62.8125,300.4844 62.5313,300.3438 62.2344,300.3438 C61.9375,300.3438 61.7344,300.4375 61.5156,300.75 L61.3438,300.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="112" x="73" y="309.8467">LinkedHashMap</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="26" x="193" y="286"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="24" x="194" y="298.1387">K, V</text><line style="stroke:#181818;stroke-width:0.5;" x1="45" x2="215" y1="321" y2="321"/><line style="stroke:#181818;stroke-width:0.5;" x1="45" x2="215" y1="329" y2="329"/></g><!--class lhm2--><g id="elem_lhm2"><rect codeLine="16" fill="#F1F1F1" height="48" id="lhm2" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="172" x="325" y="289"/><ellipse cx="340" cy="305" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M342.3438,300.6719 C341.4063,300.2344 340.8125,300.0938 339.9375,300.0938 C337.3125,300.0938 335.3125,302.1719 335.3125,304.8906 L335.3125,306.0156 C335.3125,308.5938 337.4219,310.4844 340.3125,310.4844 C341.5313,310.4844 342.6875,310.1875 343.4375,309.6406 C344.0156,309.2344 344.3438,308.7813 344.3438,308.3906 C344.3438,307.9375 343.9531,307.5469 343.4844,307.5469 C343.2656,307.5469 343.0625,307.625 342.875,307.8125 C342.4219,308.2969 342.4219,308.2969 342.2344,308.3906 C341.8125,308.6563 341.125,308.7813 340.3594,308.7813 C338.3125,308.7813 337.0156,307.6875 337.0156,305.9844 L337.0156,304.8906 C337.0156,303.1094 338.2656,301.7969 340,301.7969 C340.5781,301.7969 341.1875,301.9531 341.6563,302.2031 C342.1406,302.4844 342.3125,302.7031 342.4063,303.1094 C342.4688,303.5156 342.5,303.6406 342.6406,303.7656 C342.7813,303.9063 343.0156,304.0156 343.2344,304.0156 C343.5,304.0156 343.7656,303.875 343.9375,303.6563 C344.0469,303.5 344.0781,303.3125 344.0781,302.8906 L344.0781,301.4688 C344.0781,301.0313 344.0625,300.9063 343.9688,300.75 C343.8125,300.4844 343.5313,300.3438 343.2344,300.3438 C342.9375,300.3438 342.7344,300.4375 342.5156,300.75 L342.3438,300.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="112" x="354" y="309.8467">LinkedHashMap</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="26" x="474" y="286"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="24" x="475" y="298.1387">K, V</text><line style="stroke:#181818;stroke-width:0.5;" x1="326" x2="496" y1="321" y2="321"/><line style="stroke:#181818;stroke-width:0.5;" x1="326" x2="496" y1="329" y2="329"/></g><!--reverse link LruCountingMemoryCache to clm1--><g id="link_LruCountingMemoryCache_clm1"><path codeLine="13" d="M221.3663,96.7868 C202.6203,115.3988 188.871,129.05 170.124,147.662 " fill="none" id="LruCountingMemoryCache-backto-clm1" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="229.882,88.332,222.8059,89.7208,221.3663,96.7868,228.4424,95.3979,229.882,88.332" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link LruCountingMemoryCache to clm2--><g id="link_LruCountingMemoryCache_clm2"><path codeLine="14" d="M318.9505,96.7566 C337.8295,115.3686 351.709,129.05 370.589,147.662 " fill="none" id="LruCountingMemoryCache-backto-clm2" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="310.405,88.332,311.8695,95.3928,318.9505,96.7566,317.486,89.6958,310.405,88.332" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link clm1 to lhm1--><g id="link_clm1_lhm1"><path codeLine="17" d="M130,241.272 C130,260.9732 130,272.0687 130,288.8428 " fill="none" id="clm1-backto-lhm1" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="130,229.272,126,235.272,130,241.272,134,235.272,130,229.272" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link clm2 to lhm2--><g id="link_clm2_lhm2"><path codeLine="18" d="M411,241.272 C411,260.9732 411,272.0687 411,288.8428 " fill="none" id="clm2-backto-lhm2" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="411,229.272,407,235.272,411,241.272,415,235.272,411,229.272" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[fL2z3e8m4DvvYWkZaKHPLGODYKQOJDYRqaXZMmmjHZI-kzTQd5GqThhUVNztL12j8MlQLTqgmzK-Px9kkXMX5ODh0FZw2O9oSfnlnv0gqtIsA984P7gcejNyn6oRCptxYkKSoYVb5b2N9FpC2u5ee49EVRQCgmChrqHN7boWD9QF35mPa3j-OHkrx0pJi839prRnNrPlBZkA8hV6m3pkexumT_b4XHh36Ak3DxEgde5h-Lzy1m00]--></g></svg>

<p>LruCountingMemoryCache包含了两个CountingLruMap：<code>mCachedEntries</code>保存所有缓存数据，即缓存池；<code>mExclusiveEntries</code>是回收队列，用于保存不再被使用的数据，这些数据是可以被安全回收的。<code>CountingLruMap</code>中的数据通过<code>LinkedHashMap</code>来保存，同时CountingLruMap中有一个mSizeInBytes变量，表示缓存数据的总大小，在每次添加和删除数据时都会更新mSizeInBytes。</p>
<p>缓存池中保存的是<code>Entry&lt;K, V&gt;</code>数据类型，然而添加和获取缓存数据都会通过<code>newClientReference</code>方法来创建一个<code>CloseableReference&lt;V&gt;</code>返回的是一个<code>CloseableReference&lt;V&gt;</code>类型的数据：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//LruCountingMemoryCache.java</span></span><br><span class="line">  <span class="keyword">private</span> <span class="keyword">synchronized</span> CloseableReference&lt;V&gt; <span class="title function_">newClientReference</span><span class="params">(<span class="keyword">final</span> Entry&lt;K, V&gt; entry)</span> &#123;</span><br><span class="line">    increaseClientCount(entry);</span><br><span class="line">    <span class="keyword">return</span> CloseableReference.of(</span><br><span class="line">        entry.valueRef.get(),</span><br><span class="line">        <span class="keyword">new</span> <span class="title class_">ResourceReleaser</span>&lt;V&gt;() &#123;</span><br><span class="line">          <span class="meta">@Override</span></span><br><span class="line">          <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">release</span><span class="params">(V unused)</span> &#123; <span class="comment">//当CloseableReference#close被调用时就会执行release方法</span></span><br><span class="line">            releaseClientReference(entry);</span><br><span class="line">          &#125;</span><br><span class="line">        &#125;);</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="comment">/** Called when the client closes its reference. */</span></span><br><span class="line">  <span class="keyword">private</span> <span class="keyword">void</span> <span class="title function_">releaseClientReference</span><span class="params">(<span class="keyword">final</span> Entry&lt;K, V&gt; entry)</span> &#123;</span><br><span class="line">    Preconditions.checkNotNull(entry);</span><br><span class="line">    <span class="type">boolean</span> isExclusiveAdded;</span><br><span class="line">    CloseableReference&lt;V&gt; oldRefToClose;</span><br><span class="line">    <span class="keyword">synchronized</span> (<span class="built_in">this</span>) &#123;</span><br><span class="line">      decreaseClientCount(entry);</span><br><span class="line">      isExclusiveAdded = maybeAddToExclusives(entry);</span><br><span class="line">      oldRefToClose = referenceToClose(entry);</span><br><span class="line">    &#125;</span><br><span class="line">    CloseableReference.closeSafely(oldRefToClose);</span><br><span class="line">    maybeNotifyExclusiveEntryInsertion(isExclusiveAdded ? entry : <span class="literal">null</span>);</span><br><span class="line">    maybeUpdateCacheParams();</span><br><span class="line">    maybeEvictEntries();</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="comment">/** Adds the entry to the exclusively owned queue if it is viable for eviction. */</span></span><br><span class="line">  <span class="keyword">private</span> <span class="keyword">synchronized</span> <span class="type">boolean</span> <span class="title function_">maybeAddToExclusives</span><span class="params">(Entry&lt;K, V&gt; entry)</span> &#123;</span><br><span class="line">    <span class="keyword">if</span> (!entry.isOrphan &amp;&amp; entry.clientCount == <span class="number">0</span>) &#123;</span><br><span class="line">      mExclusiveEntries.put(entry.key, entry); <span class="comment">//添加到回收队列中</span></span><br><span class="line">      <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<p>当数据消费者不再使用这条数据时，CloseableReference#close()就会被调用，进而调用到上面代码中的release回调方法，当这条数据的使用者数量为零时，就会把这条数据添加到<code>mExclusiveEntries</code>回收队列中，<code>mCachedEntries</code>依然会保留这条数据。当从缓存池get数据时，如果这条数据在回收队列中，将会从回收队列中移除掉，因为这条数据有了使用者，就不能被回收了。</p>
<p>再来看下缓存池的配置参数：</p>
<ul>
<li>maxCacheSize 缓存的最大大小，以字节为单位；</li>
<li>maxCacheEntries 缓存中能够保存的最大数量；</li>
<li>maxEvictionQueueSize 回收队列用于存储准备回收的数据，这个字段表示回收队列的最大字节数；</li>
<li>maxEvictionQueueEntries 回收队列可以保存的最大数量；</li>
<li>maxCacheEntrySize 单个缓存数据的最大内存；</li>
<li>paramsCheckIntervalMs 检查配置参数更新的间隔时间(以毫秒为单位)。当添加缓存、获取缓存等操作时，都会检查距离上次更新配置参数是否超过这个值，如果超过了，就会重新后去这些配置参数。</li>
</ul>
<p>上面这些参数用于确定缓存池的最大容量，当超过容量限制时就会触发回收动作，回收时只会删除已经在回收队列中的数据，不在回收队列中的数据说明还再被使用，是不能回收的。在添加、获取缓存数据时都会调用<code>maybeEvictEntries</code>来判断是否要对缓存池进行清理回收：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">maybeEvictEntries</span><span class="params">()</span> &#123;</span><br><span class="line">  ArrayList&lt;Entry&lt;K, V&gt;&gt; oldEntries;</span><br><span class="line">  <span class="keyword">synchronized</span> (<span class="built_in">this</span>) &#123;</span><br><span class="line">    <span class="comment">//计算回收队列要保留的数据个数</span></span><br><span class="line">    <span class="type">int</span> <span class="variable">maxCount</span> <span class="operator">=</span></span><br><span class="line">        Math.min(</span><br><span class="line">            mMemoryCacheParams.maxEvictionQueueEntries,</span><br><span class="line">            mMemoryCacheParams.maxCacheEntries - getInUseCount());</span><br><span class="line">    <span class="comment">//计算回收队列要保留数据的总大小</span></span><br><span class="line">    <span class="type">int</span> <span class="variable">maxSize</span> <span class="operator">=</span></span><br><span class="line">        Math.min(</span><br><span class="line">            mMemoryCacheParams.maxEvictionQueueSize,</span><br><span class="line">            mMemoryCacheParams.maxCacheSize - getInUseSizeInBytes());</span><br><span class="line">    oldEntries = trimExclusivelyOwnedEntries(maxCount, maxSize);</span><br><span class="line">    makeOrphans(oldEntries);</span><br><span class="line">  &#125;</span><br><span class="line">  maybeClose(oldEntries);</span><br><span class="line">  maybeNotifyExclusiveEntryRemoval(oldEntries);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//获取正在被使用的数据的个数</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="type">int</span> <span class="title function_">getInUseCount</span><span class="params">()</span> &#123;</span><br><span class="line">  <span class="keyword">return</span> mCachedEntries.getCount() - mExclusiveEntries.getCount();</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//执行回收工作</span></span><br><span class="line"><span class="keyword">private</span> <span class="keyword">synchronized</span> ArrayList&lt;Entry&lt;K, V&gt;&gt; <span class="title function_">trimExclusivelyOwnedEntries</span><span class="params">(<span class="type">int</span> count, <span class="type">int</span> size)</span> &#123;</span><br><span class="line">  count = Math.max(count, <span class="number">0</span>);</span><br><span class="line">  size = Math.max(size, <span class="number">0</span>);</span><br><span class="line">  <span class="comment">// fast path without array allocation if no eviction is necessary</span></span><br><span class="line">  <span class="keyword">if</span> (<span class="built_in">this</span>.mExclusiveEntries.getCount() &lt;= count &amp;&amp; mExclusiveEntries.getSizeInBytes() &lt;= size) &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">null</span>;</span><br><span class="line">  &#125;</span><br><span class="line">  ArrayList&lt;Entry&lt;K, V&gt;&gt; oldEntries = <span class="keyword">new</span> <span class="title class_">ArrayList</span>&lt;&gt;();</span><br><span class="line">  <span class="comment">//循环从回收队列删除数据，直到同时满足小于等于size和count</span></span><br><span class="line">  <span class="keyword">while</span> (<span class="built_in">this</span>.mExclusiveEntries.getCount() &gt; count || mExclusiveEntries.getSizeInBytes() &gt; size) &#123;</span><br><span class="line">    <span class="meta">@Nullable</span> <span class="type">K</span> <span class="variable">key</span> <span class="operator">=</span> mExclusiveEntries.getFirstKey(); <span class="comment">//获取回收队列中最早添加的数据</span></span><br><span class="line">    ......</span><br><span class="line">    mExclusiveEntries.remove(key); <span class="comment">//从回收队列中删除</span></span><br><span class="line">    oldEntries.add(mCachedEntries.remove(key)); <span class="comment">//从缓存池删除</span></span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">return</span> oldEntries;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="内存块缓存池-MemoryChunkPool"><a href="#内存块缓存池-MemoryChunkPool" class="headerlink" title="内存块缓存池-MemoryChunkPool"></a>内存块缓存池-MemoryChunkPool</h3><?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="608px" preserveAspectRatio="none" style="width:977px;height:608px;background:#FFFFFF;" version="1.1" viewBox="0 0 977 608" width="977px" zoomAndPan="magnify"><defs/><g><!--class MemoryChunkPool--><g id="elem_MemoryChunkPool"><rect codeLine="1" fill="#F1F1F1" height="48" id="MemoryChunkPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="165" x="386" y="139"/><ellipse cx="401" cy="155" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M403.0781,156.8125 L403.4688,157.7969 L403.0781,157.7969 C402.625,157.7969 402.5156,157.8125 402.3594,157.9219 C402.1094,158.0781 401.9531,158.3594 401.9531,158.6563 C401.9531,158.9219 402.0938,159.1719 402.3125,159.3281 C402.4531,159.4531 402.6563,159.5 403.0781,159.5 L405.4375,159.5 C405.7969,159.5 406.0156,159.4688 406.1563,159.375 C406.4063,159.2344 406.5625,158.9375 406.5625,158.6563 C406.5625,158.375 406.4219,158.125 406.2031,157.9688 C406.0313,157.8281 405.875,157.7969 405.4063,157.7969 L402.0156,149.5938 L398.3438,149.5938 C397.8906,149.5938 397.7656,149.6094 397.6094,149.7031 C397.3594,149.875 397.2031,150.1563 397.2031,150.4375 C397.2031,150.7188 397.3438,150.9688 397.5625,151.1406 C397.7344,151.25 397.9063,151.2813 398.3438,151.2813 L399.4219,151.2813 L396.7813,157.7969 C396.3594,157.7969 396.2031,157.8125 396.0469,157.9219 C395.7969,158.0781 395.6406,158.3594 395.6406,158.6563 C395.6406,159.2188 396.0156,159.5 396.7656,159.5 L399.0313,159.5 C399.3906,159.5 399.6094,159.4688 399.7344,159.375 C400,159.2344 400.1406,158.9375 400.1406,158.6563 C400.1406,158.375 400.0156,158.125 399.7969,157.9531 C399.625,157.8281 399.4844,157.7969 399.0313,157.7969 L398.6406,157.7969 L399.0313,156.8125 L403.0781,156.8125 Z M402.375,155.1094 L399.7031,155.1094 L401.0469,151.8438 L402.375,155.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="133" x="415" y="159.8467">MemoryChunkPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="387" x2="550" y1="171" y2="171"/><line style="stroke:#181818;stroke-width:0.5;" x1="387" x2="550" y1="179" y2="179"/></g><!--class BufferMemoryChunkPool--><g id="elem_BufferMemoryChunkPool"><rect fill="#F1F1F1" height="48" id="BufferMemoryChunkPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="211" x="7" y="319"/><ellipse cx="22" cy="335" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M24.3438,330.6719 C23.4063,330.2344 22.8125,330.0938 21.9375,330.0938 C19.3125,330.0938 17.3125,332.1719 17.3125,334.8906 L17.3125,336.0156 C17.3125,338.5938 19.4219,340.4844 22.3125,340.4844 C23.5313,340.4844 24.6875,340.1875 25.4375,339.6406 C26.0156,339.2344 26.3438,338.7813 26.3438,338.3906 C26.3438,337.9375 25.9531,337.5469 25.4844,337.5469 C25.2656,337.5469 25.0625,337.625 24.875,337.8125 C24.4219,338.2969 24.4219,338.2969 24.2344,338.3906 C23.8125,338.6563 23.125,338.7813 22.3594,338.7813 C20.3125,338.7813 19.0156,337.6875 19.0156,335.9844 L19.0156,334.8906 C19.0156,333.1094 20.2656,331.7969 22,331.7969 C22.5781,331.7969 23.1875,331.9531 23.6563,332.2031 C24.1406,332.4844 24.3125,332.7031 24.4063,333.1094 C24.4688,333.5156 24.5,333.6406 24.6406,333.7656 C24.7813,333.9063 25.0156,334.0156 25.2344,334.0156 C25.5,334.0156 25.7656,333.875 25.9375,333.6563 C26.0469,333.5 26.0781,333.3125 26.0781,332.8906 L26.0781,331.4688 C26.0781,331.0313 26.0625,330.9063 25.9688,330.75 C25.8125,330.4844 25.5313,330.3438 25.2344,330.3438 C24.9375,330.3438 24.7344,330.4375 24.5156,330.75 L24.3438,330.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="179" x="36" y="339.8467">BufferMemoryChunkPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="217" y1="351" y2="351"/><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="217" y1="359" y2="359"/></g><!--class BufferMemoryChunk--><g id="elem_BufferMemoryChunk"><rect fill="#F1F1F1" height="48" id="BufferMemoryChunk" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="180" x="49.5" y="444"/><ellipse cx="64.5" cy="460" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M66.8438,455.6719 C65.9063,455.2344 65.3125,455.0938 64.4375,455.0938 C61.8125,455.0938 59.8125,457.1719 59.8125,459.8906 L59.8125,461.0156 C59.8125,463.5938 61.9219,465.4844 64.8125,465.4844 C66.0313,465.4844 67.1875,465.1875 67.9375,464.6406 C68.5156,464.2344 68.8438,463.7813 68.8438,463.3906 C68.8438,462.9375 68.4531,462.5469 67.9844,462.5469 C67.7656,462.5469 67.5625,462.625 67.375,462.8125 C66.9219,463.2969 66.9219,463.2969 66.7344,463.3906 C66.3125,463.6563 65.625,463.7813 64.8594,463.7813 C62.8125,463.7813 61.5156,462.6875 61.5156,460.9844 L61.5156,459.8906 C61.5156,458.1094 62.7656,456.7969 64.5,456.7969 C65.0781,456.7969 65.6875,456.9531 66.1563,457.2031 C66.6406,457.4844 66.8125,457.7031 66.9063,458.1094 C66.9688,458.5156 67,458.6406 67.1406,458.7656 C67.2813,458.9063 67.5156,459.0156 67.7344,459.0156 C68,459.0156 68.2656,458.875 68.4375,458.6563 C68.5469,458.5 68.5781,458.3125 68.5781,457.8906 L68.5781,456.4688 C68.5781,456.0313 68.5625,455.9063 68.4688,455.75 C68.3125,455.4844 68.0313,455.3438 67.7344,455.3438 C67.4375,455.3438 67.2344,455.4375 67.0156,455.75 L66.8438,455.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="148" x="78.5" y="464.8467">BufferMemoryChunk</text><line style="stroke:#181818;stroke-width:0.5;" x1="50.5" x2="228.5" y1="476" y2="476"/><line style="stroke:#181818;stroke-width:0.5;" x1="50.5" x2="228.5" y1="484" y2="484"/></g><!--class AshmemMemoryChunkPool--><g id="elem_AshmemMemoryChunkPool"><rect fill="#F1F1F1" height="48" id="AshmemMemoryChunkPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="229" x="253" y="319"/><ellipse cx="268" cy="335" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M270.3438,330.6719 C269.4063,330.2344 268.8125,330.0938 267.9375,330.0938 C265.3125,330.0938 263.3125,332.1719 263.3125,334.8906 L263.3125,336.0156 C263.3125,338.5938 265.4219,340.4844 268.3125,340.4844 C269.5313,340.4844 270.6875,340.1875 271.4375,339.6406 C272.0156,339.2344 272.3438,338.7813 272.3438,338.3906 C272.3438,337.9375 271.9531,337.5469 271.4844,337.5469 C271.2656,337.5469 271.0625,337.625 270.875,337.8125 C270.4219,338.2969 270.4219,338.2969 270.2344,338.3906 C269.8125,338.6563 269.125,338.7813 268.3594,338.7813 C266.3125,338.7813 265.0156,337.6875 265.0156,335.9844 L265.0156,334.8906 C265.0156,333.1094 266.2656,331.7969 268,331.7969 C268.5781,331.7969 269.1875,331.9531 269.6563,332.2031 C270.1406,332.4844 270.3125,332.7031 270.4063,333.1094 C270.4688,333.5156 270.5,333.6406 270.6406,333.7656 C270.7813,333.9063 271.0156,334.0156 271.2344,334.0156 C271.5,334.0156 271.7656,333.875 271.9375,333.6563 C272.0469,333.5 272.0781,333.3125 272.0781,332.8906 L272.0781,331.4688 C272.0781,331.0313 272.0625,330.9063 271.9688,330.75 C271.8125,330.4844 271.5313,330.3438 271.2344,330.3438 C270.9375,330.3438 270.7344,330.4375 270.5156,330.75 L270.3438,330.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="197" x="282" y="339.8467">AshmemMemoryChunkPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="254" x2="481" y1="351" y2="351"/><line style="stroke:#181818;stroke-width:0.5;" x1="254" x2="481" y1="359" y2="359"/></g><!--class NativeMemoryChunkPool--><g id="elem_NativeMemoryChunkPool"><rect fill="#F1F1F1" height="48" id="NativeMemoryChunkPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="212" x="517.5" y="319"/><ellipse cx="532.5" cy="335" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M534.8438,330.6719 C533.9063,330.2344 533.3125,330.0938 532.4375,330.0938 C529.8125,330.0938 527.8125,332.1719 527.8125,334.8906 L527.8125,336.0156 C527.8125,338.5938 529.9219,340.4844 532.8125,340.4844 C534.0313,340.4844 535.1875,340.1875 535.9375,339.6406 C536.5156,339.2344 536.8438,338.7813 536.8438,338.3906 C536.8438,337.9375 536.4531,337.5469 535.9844,337.5469 C535.7656,337.5469 535.5625,337.625 535.375,337.8125 C534.9219,338.2969 534.9219,338.2969 534.7344,338.3906 C534.3125,338.6563 533.625,338.7813 532.8594,338.7813 C530.8125,338.7813 529.5156,337.6875 529.5156,335.9844 L529.5156,334.8906 C529.5156,333.1094 530.7656,331.7969 532.5,331.7969 C533.0781,331.7969 533.6875,331.9531 534.1563,332.2031 C534.6406,332.4844 534.8125,332.7031 534.9063,333.1094 C534.9688,333.5156 535,333.6406 535.1406,333.7656 C535.2813,333.9063 535.5156,334.0156 535.7344,334.0156 C536,334.0156 536.2656,333.875 536.4375,333.6563 C536.5469,333.5 536.5781,333.3125 536.5781,332.8906 L536.5781,331.4688 C536.5781,331.0313 536.5625,330.9063 536.4688,330.75 C536.3125,330.4844 536.0313,330.3438 535.7344,330.3438 C535.4375,330.3438 535.2344,330.4375 535.0156,330.75 L534.8438,330.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="180" x="546.5" y="339.8467">NativeMemoryChunkPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="518.5" x2="728.5" y1="351" y2="351"/><line style="stroke:#181818;stroke-width:0.5;" x1="518.5" x2="728.5" y1="359" y2="359"/></g><!--class NativeMemoryChunk--><g id="elem_NativeMemoryChunk"><rect fill="#F1F1F1" height="48" id="NativeMemoryChunk" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="181" x="510" y="444"/><ellipse cx="525" cy="460" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M527.3438,455.6719 C526.4063,455.2344 525.8125,455.0938 524.9375,455.0938 C522.3125,455.0938 520.3125,457.1719 520.3125,459.8906 L520.3125,461.0156 C520.3125,463.5938 522.4219,465.4844 525.3125,465.4844 C526.5313,465.4844 527.6875,465.1875 528.4375,464.6406 C529.0156,464.2344 529.3438,463.7813 529.3438,463.3906 C529.3438,462.9375 528.9531,462.5469 528.4844,462.5469 C528.2656,462.5469 528.0625,462.625 527.875,462.8125 C527.4219,463.2969 527.4219,463.2969 527.2344,463.3906 C526.8125,463.6563 526.125,463.7813 525.3594,463.7813 C523.3125,463.7813 522.0156,462.6875 522.0156,460.9844 L522.0156,459.8906 C522.0156,458.1094 523.2656,456.7969 525,456.7969 C525.5781,456.7969 526.1875,456.9531 526.6563,457.2031 C527.1406,457.4844 527.3125,457.7031 527.4063,458.1094 C527.4688,458.5156 527.5,458.6406 527.6406,458.7656 C527.7813,458.9063 528.0156,459.0156 528.2344,459.0156 C528.5,459.0156 528.7656,458.875 528.9375,458.6563 C529.0469,458.5 529.0781,458.3125 529.0781,457.8906 L529.0781,456.4688 C529.0781,456.0313 529.0625,455.9063 528.9688,455.75 C528.8125,455.4844 528.5313,455.3438 528.2344,455.3438 C527.9375,455.3438 527.7344,455.4375 527.5156,455.75 L527.3438,455.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="149" x="539" y="464.8467">NativeMemoryChunk</text><line style="stroke:#181818;stroke-width:0.5;" x1="511" x2="690" y1="476" y2="476"/><line style="stroke:#181818;stroke-width:0.5;" x1="511" x2="690" y1="484" y2="484"/></g><!--class MemoryChunk--><g id="elem_MemoryChunk"><rect codeLine="7" fill="#F1F1F1" height="48" id="MemoryChunk" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="135" x="396" y="553"/><ellipse cx="411" cy="569" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M411.9531,565.7813 L413.6719,565.7813 C414.0625,565.7813 414.25,565.75 414.375,565.6719 C414.6406,565.5156 414.7813,565.2344 414.7813,564.9375 C414.7813,564.6719 414.6719,564.4063 414.4375,564.2344 C414.2656,564.125 414.125,564.0938 413.6719,564.0938 L408.5313,564.0938 C408.0938,564.0938 407.9688,564.1094 407.8125,564.2031 C407.5625,564.3594 407.4063,564.6563 407.4063,564.9375 C407.4063,565.2188 407.5469,565.4688 407.7656,565.6406 C407.9219,565.75 408.1094,565.7813 408.5313,565.7813 L410.25,565.7813 L410.25,572.2969 L408.5313,572.2969 C408.0938,572.2969 407.9688,572.3125 407.8125,572.4219 C407.5625,572.5781 407.4063,572.8594 407.4063,573.1563 C407.4063,573.4063 407.5469,573.6719 407.7656,573.8281 C407.9219,573.9531 408.125,574 408.5313,574 L413.6719,574 C414.4219,574 414.7813,573.7188 414.7813,573.1563 C414.7813,572.875 414.6719,572.625 414.4375,572.4531 C414.2656,572.3281 414.125,572.2969 413.6719,572.2969 L411.9531,572.2969 L411.9531,565.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="103" x="425" y="573.8467">MemoryChunk</text><line style="stroke:#181818;stroke-width:0.5;" x1="397" x2="530" y1="585" y2="585"/><line style="stroke:#181818;stroke-width:0.5;" x1="397" x2="530" y1="593" y2="593"/></g><!--class AshmemMemoryChunk--><g id="elem_AshmemMemoryChunk"><rect fill="#F1F1F1" height="48" id="AshmemMemoryChunk" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="198" x="274.5" y="444"/><ellipse cx="289.5" cy="460" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M291.8438,455.6719 C290.9063,455.2344 290.3125,455.0938 289.4375,455.0938 C286.8125,455.0938 284.8125,457.1719 284.8125,459.8906 L284.8125,461.0156 C284.8125,463.5938 286.9219,465.4844 289.8125,465.4844 C291.0313,465.4844 292.1875,465.1875 292.9375,464.6406 C293.5156,464.2344 293.8438,463.7813 293.8438,463.3906 C293.8438,462.9375 293.4531,462.5469 292.9844,462.5469 C292.7656,462.5469 292.5625,462.625 292.375,462.8125 C291.9219,463.2969 291.9219,463.2969 291.7344,463.3906 C291.3125,463.6563 290.625,463.7813 289.8594,463.7813 C287.8125,463.7813 286.5156,462.6875 286.5156,460.9844 L286.5156,459.8906 C286.5156,458.1094 287.7656,456.7969 289.5,456.7969 C290.0781,456.7969 290.6875,456.9531 291.1563,457.2031 C291.6406,457.4844 291.8125,457.7031 291.9063,458.1094 C291.9688,458.5156 292,458.6406 292.1406,458.7656 C292.2813,458.9063 292.5156,459.0156 292.7344,459.0156 C293,459.0156 293.2656,458.875 293.4375,458.6563 C293.5469,458.5 293.5781,458.3125 293.5781,457.8906 L293.5781,456.4688 C293.5781,456.0313 293.5625,455.9063 293.4688,455.75 C293.3125,455.4844 293.0313,455.3438 292.7344,455.3438 C292.4375,455.3438 292.2344,455.4375 292.0156,455.75 L291.8438,455.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="166" x="303.5" y="464.8467">AshmemMemoryChunk</text><line style="stroke:#181818;stroke-width:0.5;" x1="275.5" x2="471.5" y1="476" y2="476"/><line style="stroke:#181818;stroke-width:0.5;" x1="275.5" x2="471.5" y1="484" y2="484"/></g><!--class BasePool--><g id="elem_BasePool"><rect codeLine="13" fill="#F1F1F1" height="64.2969" id="BasePool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="373" x="383" y="10"/><ellipse cx="487.25" cy="26" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M489.3281,27.8125 L489.7188,28.7969 L489.3281,28.7969 C488.875,28.7969 488.7656,28.8125 488.6094,28.9219 C488.3594,29.0781 488.2031,29.3594 488.2031,29.6563 C488.2031,29.9219 488.3438,30.1719 488.5625,30.3281 C488.7031,30.4531 488.9063,30.5 489.3281,30.5 L491.6875,30.5 C492.0469,30.5 492.2656,30.4688 492.4063,30.375 C492.6563,30.2344 492.8125,29.9375 492.8125,29.6563 C492.8125,29.375 492.6719,29.125 492.4531,28.9688 C492.2813,28.8281 492.125,28.7969 491.6563,28.7969 L488.2656,20.5938 L484.5938,20.5938 C484.1406,20.5938 484.0156,20.6094 483.8594,20.7031 C483.6094,20.875 483.4531,21.1563 483.4531,21.4375 C483.4531,21.7188 483.5938,21.9688 483.8125,22.1406 C483.9844,22.25 484.1563,22.2813 484.5938,22.2813 L485.6719,22.2813 L483.0313,28.7969 C482.6094,28.7969 482.4531,28.8125 482.2969,28.9219 C482.0469,29.0781 481.8906,29.3594 481.8906,29.6563 C481.8906,30.2188 482.2656,30.5 483.0156,30.5 L485.2813,30.5 C485.6406,30.5 485.8594,30.4688 485.9844,30.375 C486.25,30.2344 486.3906,29.9375 486.3906,29.6563 C486.3906,29.375 486.2656,29.125 486.0469,28.9531 C485.875,28.8281 485.7344,28.7969 485.2813,28.7969 L484.8906,28.7969 L485.2813,27.8125 L489.3281,27.8125 Z M488.625,26.1094 L485.9531,26.1094 L487.2969,22.8438 L488.625,26.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="65" x="507.75" y="30.8467">BasePool</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="89" x="670" y="7"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="87" x="671" y="19.1387">MemoryChunk</text><line style="stroke:#181818;stroke-width:0.5;" x1="384" x2="755" y1="42" y2="42"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="361" x="389" y="58.9951">SparseArray&lt;Bucket&lt;MemoryChunk&gt;&gt; mBuckets</text><line style="stroke:#181818;stroke-width:0.5;" x1="384" x2="755" y1="66.2969" y2="66.2969"/></g><!--class Bucket--><g id="elem_Bucket"><rect codeLine="19" fill="#F1F1F1" height="64.2969" id="Bucket" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="258" x="626.5" y="221"/><ellipse cx="680.25" cy="237" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M682.5938,232.6719 C681.6563,232.2344 681.0625,232.0938 680.1875,232.0938 C677.5625,232.0938 675.5625,234.1719 675.5625,236.8906 L675.5625,238.0156 C675.5625,240.5938 677.6719,242.4844 680.5625,242.4844 C681.7813,242.4844 682.9375,242.1875 683.6875,241.6406 C684.2656,241.2344 684.5938,240.7813 684.5938,240.3906 C684.5938,239.9375 684.2031,239.5469 683.7344,239.5469 C683.5156,239.5469 683.3125,239.625 683.125,239.8125 C682.6719,240.2969 682.6719,240.2969 682.4844,240.3906 C682.0625,240.6563 681.375,240.7813 680.6094,240.7813 C678.5625,240.7813 677.2656,239.6875 677.2656,237.9844 L677.2656,236.8906 C677.2656,235.1094 678.5156,233.7969 680.25,233.7969 C680.8281,233.7969 681.4375,233.9531 681.9063,234.2031 C682.3906,234.4844 682.5625,234.7031 682.6563,235.1094 C682.7188,235.5156 682.75,235.6406 682.8906,235.7656 C683.0313,235.9063 683.2656,236.0156 683.4844,236.0156 C683.75,236.0156 684.0156,235.875 684.1875,235.6563 C684.2969,235.5 684.3281,235.3125 684.3281,234.8906 L684.3281,233.4688 C684.3281,233.0313 684.3125,232.9063 684.2188,232.75 C684.0625,232.4844 683.7813,232.3438 683.4844,232.3438 C683.1875,232.3438 682.9844,232.4375 682.7656,232.75 L682.5938,232.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="51" x="700.75" y="241.8467">Bucket</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="89" x="798.5" y="218"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="87" x="799.5" y="230.1387">MemoryChunk</text><line style="stroke:#181818;stroke-width:0.5;" x1="627.5" x2="883.5" y1="253" y2="253"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="246" x="632.5" y="269.9951">Queue&lt;MemoryChunk&gt; mFreeList</text><line style="stroke:#181818;stroke-width:0.5;" x1="627.5" x2="883.5" y1="277.2969" y2="277.2969"/></g><!--link BufferMemoryChunkPool to BufferMemoryChunk--><g id="link_BufferMemoryChunkPool_BufferMemoryChunk"><path codeLine="2" d="M117.578,367.135 C122.406,389.126 128.3387,416.1515 133.1577,438.1075 " fill="none" id="BufferMemoryChunkPool-to-BufferMemoryChunk" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="134.444,443.968,136.4216,434.3197,133.3721,439.0842,128.6076,436.0348,134.444,443.968" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="27" x="129.5" y="410.0669">new</text></g><!--reverse link MemoryChunkPool to BufferMemoryChunkPool--><g id="link_MemoryChunkPool_BufferMemoryChunkPool"><path codeLine="3" d="M406.2243,195.1378 C337.9313,229.2838 226.84,284.83 158.594,318.953 " fill="none" id="MemoryChunkPool-backto-BufferMemoryChunkPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="422.324,187.088,403.541,189.7712,408.9075,200.5043,422.324,187.088" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link MemoryChunkPool to AshmemMemoryChunkPool--><g id="link_MemoryChunkPool_AshmemMemoryChunkPool"><path codeLine="4" d="M446.4128,202.9253 C427.0558,237.0393 400.066,284.607 380.707,318.724 " fill="none" id="MemoryChunkPool-backto-AshmemMemoryChunkPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="455.296,187.27,441.1944,199.9643,451.6313,205.8864,455.296,187.27" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link MemoryChunkPool to NativeMemoryChunkPool--><g id="link_MemoryChunkPool_NativeMemoryChunkPool"><path codeLine="5" d="M500.5844,200.8449 C530.2894,234.9589 573.523,284.607 603.231,318.724 " fill="none" id="MemoryChunkPool-backto-NativeMemoryChunkPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="488.764,187.27,496.0595,204.785,505.1094,196.9047,488.764,187.27" style="stroke:#181818;stroke-width:1.0;"/></g><!--link NativeMemoryChunkPool to NativeMemoryChunk--><g id="link_NativeMemoryChunkPool_NativeMemoryChunk"><path codeLine="6" d="M619.174,367.135 C615.062,389.126 610.0147,416.1142 605.9097,438.0702 " fill="none" id="NativeMemoryChunkPool-to-NativeMemoryChunk" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="604.807,443.968,610.3929,435.8564,605.7259,439.0532,602.5292,434.3862,604.807,443.968" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="27" x="614.5" y="410.0669">new</text></g><!--link NativeMemoryChunk to MemoryChunk--><g id="link_NativeMemoryChunk_MemoryChunk"><path codeLine="8" d="M570.773,492.217 C547.794,510.1649 530.32,523.8122 507.355,541.7483 " fill="none" id="NativeMemoryChunk-to-MemoryChunk" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="493.169,552.8279,511.0482,546.477,503.6618,537.0197,493.169,552.8279" style="stroke:#181818;stroke-width:1.0;"/></g><!--link BufferMemoryChunk to MemoryChunk--><g id="link_BufferMemoryChunk_MemoryChunk"><path codeLine="9" d="M209.404,492.086 C264.655,510.3321 324.2149,530.0016 378.8479,548.044 " fill="none" id="BufferMemoryChunk-to-MemoryChunk" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="395.94,553.6886,380.7295,542.3466,376.9664,553.7413,395.94,553.6886" style="stroke:#181818;stroke-width:1.0;"/></g><!--link AshmemMemoryChunkPool to AshmemMemoryChunk--><g id="link_AshmemMemoryChunkPool_AshmemMemoryChunk"><path codeLine="10" d="M368.629,367.135 C369.701,389.126 371.0124,416.0191 372.0844,437.9751 " fill="none" id="AshmemMemoryChunkPool-to-AshmemMemoryChunk" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="372.377,443.968,375.9333,434.7836,372.1332,438.9739,367.9429,435.1738,372.377,443.968" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="27" x="372.5" y="410.0669">new</text></g><!--link AshmemMemoryChunk to MemoryChunk--><g id="link_AshmemMemoryChunk_MemoryChunk"><path codeLine="11" d="M393.029,492.217 C408.125,510.1649 417.3367,521.1166 432.4227,539.0527 " fill="none" id="AshmemMemoryChunk-to-MemoryChunk" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="444.009,552.8279,437.0144,535.1906,427.8309,542.9148,444.009,552.8279" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BasePool to MemoryChunkPool--><g id="link_BasePool_MemoryChunkPool"><path codeLine="16" d="M528.0954,91.7835 C511.4534,111.3915 502.822,121.562 488.161,138.835 " fill="none" id="BasePool-backto-MemoryChunkPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="539.743,78.06,523.5209,87.9009,532.6699,95.666,539.743,78.06" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BasePool to Bucket--><g id="link_BasePool_Bucket"><path codeLine="22" d="M769.5,54 C833.785,54 791.086,159.65 769.868,216.602 " fill="none" id="BasePool-backto-Bucket" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="757.5,54,763.5,58,769.5,54,763.5,50,757.5,54" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="8" x="763.8" y="51.2119">1</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="8" x="762.759" y="209.8894">n</text></g><!--reverse link Bucket to MemoryChunk--><g id="link_Bucket_MemoryChunk"><path codeLine="23" d="M897.5,265 C922.835,265 970.476,315.296 708.5,492 C654.447,528.459 583.026,550.5653 531.253,562.8812 " fill="none" id="Bucket-backto-MemoryChunk" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="885.5,265,891.5,269,897.5,265,891.5,261,885.5,265" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="8" x="892.4094" y="262.2947">1</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="8" x="539.101" y="557.5908">n</text></g><!--SRC=[ZPBFYi8m48VlynH3ZmivU2sbO1SygQpi4yoMAHPDA_cp8kgxRxGDj9qSDfV2_BvyCqbAFzOPgXtMPx8MTwnxS_iy-kxqrVTdg7pJi5bKKQaIHO8vTdo59LiybCAa9eskxL6p_XUw9zV-yX9DLjyZYsGSkUqScuPgdXvVUeBZKSuGUGS2IHxdFOr8ncbaNKY1ugjLPFbbB2PnYNV0iBulP2olZQ5RKVdwn6v6bQY7geMdk5_bBw-cKGy0m_-Hy8pT3fuzpmEzCSpRrhhG89hoF7R5R9NXHtZ6hCj6BmoVmCITCsWY_mC0]--></g></svg>

<p>Fresco默认使用<code>NativeMemoryChunkPool</code>，而如果要使用<code>AshmemMemoryChunkPool</code>则必须配置开发打开，并且8.1及以上的android版本才能使用（<code>ImagePipelineConfig#getMemoryChunkType</code>）。</p>
<ul>
<li>NativeMemoryChunk使用nativce内存，通过C函数malloc来申请内存；</li>
<li>AshmemMemoryChunk使用匿名共享内存，通过<code>android.os.SharedMemory#create</code>来申请内存；</li>
<li>BufferMemoryChunk使用Java堆上的内存，通过<code>java.nio.ByteBuffer#allocateDirect</code>来申请内存；</li>
</ul>
<p>MemoryChunkPool中维护了一个int数组（mBucketSizes），是内存块大小列表，数组的值来自<code>PoolParams#bucketSizes</code>的keys，此处不会使用其value值。<code>PoolParams#bucketSizes</code>是个SparseIntArray类型，相当于map类型，key、value都是int。key表示内存块大小、value表示该大小的内存块的个数。默认值如下<small>（<em>默认值在<code>DefaultNativeMemoryChunkPoolParams#get</code>赋值</em>）</small>：</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="264px" preserveAspectRatio="none" style="width:212px;height:264px;background:#FFFFFF;" version="1.1" viewBox="0 0 212 264" width="212px" zoomAndPan="magnify"><defs/><g><g id="elem_bucketSizes"><rect fill="#F1F1F1" height="243.5625" style="stroke:#181818;stroke-width:0.5;" width="191" x="7" y="7"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="177" x="14" y="21.9951">bucketSizes key=&gt;value</text><line style="stroke:#181818;stroke-width:1.0;" x1="7" x2="198" y1="27.2969" y2="27.2969"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="77" x="29.5" y="42.292">1024 (1KB)</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="9" x="134" y="42.292">5</text><line style="stroke:#181818;stroke-width:1.0;" x1="129" x2="129" y1="27.2969" y2="47.5938"/><line style="stroke:#181818;stroke-width:1.0;" x1="7" x2="198" y1="47.5938" y2="47.5938"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="75" x="30.5" y="62.5889">2048 (2KB)</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="9" x="134" y="62.5889">5</text><line style="stroke:#181818;stroke-width:1.0;" x1="129" x2="129" y1="47.5938" y2="67.8906"/><line style="stroke:#181818;stroke-width:1.0;" x1="7" x2="198" y1="67.8906" y2="67.8906"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="77" x="29.5" y="82.8857">4096 (4KB)</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="9" x="134" y="82.8857">5</text><line style="stroke:#181818;stroke-width:1.0;" x1="129" x2="129" y1="67.8906" y2="88.1875"/><line style="stroke:#181818;stroke-width:1.0;" x1="7" x2="198" y1="88.1875" y2="88.1875"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="76" x="30" y="103.1826">8192 (8KB)</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="9" x="134" y="103.1826">5</text><line style="stroke:#181818;stroke-width:1.0;" x1="129" x2="129" y1="88.1875" y2="108.4844"/><line style="stroke:#181818;stroke-width:1.0;" x1="7" x2="198" y1="108.4844" y2="108.4844"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="95" x="20.5" y="123.4795">16384 (16KB)</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="9" x="134" y="123.4795">5</text><line style="stroke:#181818;stroke-width:1.0;" x1="129" x2="129" y1="108.4844" y2="128.7813"/><line style="stroke:#181818;stroke-width:1.0;" x1="7" x2="198" y1="128.7813" y2="128.7813"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="94" x="21" y="143.7764">32768 (32KB)</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="9" x="134" y="143.7764">5</text><line style="stroke:#181818;stroke-width:1.0;" x1="129" x2="129" y1="128.7813" y2="149.0781"/><line style="stroke:#181818;stroke-width:1.0;" x1="7" x2="198" y1="149.0781" y2="149.0781"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="96" x="20" y="164.0732">65536 (64KB)</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="9" x="134" y="164.0732">5</text><line style="stroke:#181818;stroke-width:1.0;" x1="129" x2="129" y1="149.0781" y2="169.375"/><line style="stroke:#181818;stroke-width:1.0;" x1="7" x2="198" y1="169.375" y2="169.375"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="112" x="12" y="184.3701">131072 (128KB)</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="9" x="134" y="184.3701">5</text><line style="stroke:#181818;stroke-width:1.0;" x1="129" x2="129" y1="169.375" y2="189.6719"/><line style="stroke:#181818;stroke-width:1.0;" x1="7" x2="198" y1="189.6719" y2="189.6719"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="110" x="13" y="204.667">262144 (256KB)</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="8" x="134" y="204.667">2</text><line style="stroke:#181818;stroke-width:1.0;" x1="129" x2="129" y1="189.6719" y2="209.9688"/><line style="stroke:#181818;stroke-width:1.0;" x1="7" x2="198" y1="209.9688" y2="209.9688"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="109" x="13.5" y="224.9639">524288 (512KB)</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="8" x="134" y="224.9639">2</text><line style="stroke:#181818;stroke-width:1.0;" x1="129" x2="129" y1="209.9688" y2="230.2656"/><line style="stroke:#181818;stroke-width:1.0;" x1="7" x2="198" y1="230.2656" y2="230.2656"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="106" x="15" y="245.2607">1048576 (1MB)</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="8" x="134" y="245.2607">2</text><line style="stroke:#181818;stroke-width:1.0;" x1="129" x2="129" y1="230.2656" y2="250.5625"/></g><!--SRC=[LS-n2i903CRntQS8dSxjahlahaCxk8gJJt3A3L85eQsWuhiR2mMJyH_umNShTsXEytceq_7ogYCCzTdrZtATQmDbXF_NUmDww2c2m_rk2rqFl3JoCOCZqw9l1LmqBMDBuB9fA27_G34rK18bWpM5EIWgLiM0FgcBP6KImgWqyMhJqfaYPSKPoNJK5PpKnyEQFry0]--></g></svg>

<p>当需要获取内存块时，会调用<code>MemoryChunkPool#get(int size)</code>来获取一个MemoryChunk。比如要获取一个60KB大小的内存块，就会在mBucketSizes数组中找大于等于60KB的最小值，所以，最终内存块大小是64KB。申请内存块时，如果内存池中已经有对应大小的内存块就返回，否则会创建一个新的内存块，并申请内存。</p>
<p><code>Bucket&lt;MemoryChunk&gt;</code>中维护的都是相同大小的内存块，使用一个Queue维护空闲的内存块，当内存块被取走后，就在Queue中删除了。当内存块使用完后再放入Queue中。</p>
<p><strong>使用场景：</strong></p>
<ul>
<li>NetworkFetchProducer中，图片从网络下载后，原始图片数据就会写入到一个MemoryChunk中。</li>
</ul>
<h3 id="字节内存缓存池-ByteArrayPool"><a href="#字节内存缓存池-ByteArrayPool" class="headerlink" title="字节内存缓存池 ByteArrayPool"></a>字节内存缓存池 ByteArrayPool</h3><?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="281px" preserveAspectRatio="none" style="width:342px;height:281px;background:#FFFFFF;" version="1.1" viewBox="0 0 342 281" width="342px" zoomAndPan="magnify"><defs/><g><!--class BasePool--><g id="elem_BasePool"><rect codeLine="1" fill="#F1F1F1" height="48" id="BasePool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="160" x="7" y="118"/><ellipse cx="22" cy="134" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M24.3438,129.6719 C23.4063,129.2344 22.8125,129.0938 21.9375,129.0938 C19.3125,129.0938 17.3125,131.1719 17.3125,133.8906 L17.3125,135.0156 C17.3125,137.5938 19.4219,139.4844 22.3125,139.4844 C23.5313,139.4844 24.6875,139.1875 25.4375,138.6406 C26.0156,138.2344 26.3438,137.7813 26.3438,137.3906 C26.3438,136.9375 25.9531,136.5469 25.4844,136.5469 C25.2656,136.5469 25.0625,136.625 24.875,136.8125 C24.4219,137.2969 24.4219,137.2969 24.2344,137.3906 C23.8125,137.6563 23.125,137.7813 22.3594,137.7813 C20.3125,137.7813 19.0156,136.6875 19.0156,134.9844 L19.0156,133.8906 C19.0156,132.1094 20.2656,130.7969 22,130.7969 C22.5781,130.7969 23.1875,130.9531 23.6563,131.2031 C24.1406,131.4844 24.3125,131.7031 24.4063,132.1094 C24.4688,132.5156 24.5,132.6406 24.6406,132.7656 C24.7813,132.9063 25.0156,133.0156 25.2344,133.0156 C25.5,133.0156 25.7656,132.875 25.9375,132.6563 C26.0469,132.5 26.0781,132.3125 26.0781,131.8906 L26.0781,130.4688 C26.0781,130.0313 26.0625,129.9063 25.9688,129.75 C25.8125,129.4844 25.5313,129.3438 25.2344,129.3438 C24.9375,129.3438 24.7344,129.4375 24.5156,129.75 L24.3438,129.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="65" x="36" y="138.8467">BasePool</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="61" x="109" y="115"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="59" x="110" y="127.1387">ByteArray</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="166" y1="150" y2="150"/><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="166" y1="158" y2="158"/></g><!--class Pool--><g id="elem_Pool"><rect codeLine="2" fill="#F1F1F1" height="48" id="Pool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="107" x="215.5" y="10"/><ellipse cx="230.5" cy="26" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M231.4531,22.7813 L233.1719,22.7813 C233.5625,22.7813 233.75,22.75 233.875,22.6719 C234.1406,22.5156 234.2813,22.2344 234.2813,21.9375 C234.2813,21.6719 234.1719,21.4063 233.9375,21.2344 C233.7656,21.125 233.625,21.0938 233.1719,21.0938 L228.0313,21.0938 C227.5938,21.0938 227.4688,21.1094 227.3125,21.2031 C227.0625,21.3594 226.9063,21.6563 226.9063,21.9375 C226.9063,22.2188 227.0469,22.4688 227.2656,22.6406 C227.4219,22.75 227.6094,22.7813 228.0313,22.7813 L229.75,22.7813 L229.75,29.2969 L228.0313,29.2969 C227.5938,29.2969 227.4688,29.3125 227.3125,29.4219 C227.0625,29.5781 226.9063,29.8594 226.9063,30.1563 C226.9063,30.4063 227.0469,30.6719 227.2656,30.8281 C227.4219,30.9531 227.625,31 228.0313,31 L233.1719,31 C233.9219,31 234.2813,30.7188 234.2813,30.1563 C234.2813,29.875 234.1719,29.625 233.9375,29.4531 C233.7656,29.3281 233.625,29.2969 233.1719,29.2969 L231.4531,29.2969 L231.4531,22.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="30" x="244.5" y="30.8467">Pool</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="43" x="282.5" y="7"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="41" x="283.5" y="19.1387">byte []</text><line style="stroke:#181818;stroke-width:0.5;" x1="216.5" x2="321.5" y1="42" y2="42"/><line style="stroke:#181818;stroke-width:0.5;" x1="216.5" x2="321.5" y1="50" y2="50"/></g><!--class ByteArrayPool--><g id="elem_ByteArrayPool"><rect codeLine="3" fill="#F1F1F1" height="48" id="ByteArrayPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="133" x="202.5" y="118"/><ellipse cx="217.5" cy="134" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M218.4531,130.7813 L220.1719,130.7813 C220.5625,130.7813 220.75,130.75 220.875,130.6719 C221.1406,130.5156 221.2813,130.2344 221.2813,129.9375 C221.2813,129.6719 221.1719,129.4063 220.9375,129.2344 C220.7656,129.125 220.625,129.0938 220.1719,129.0938 L215.0313,129.0938 C214.5938,129.0938 214.4688,129.1094 214.3125,129.2031 C214.0625,129.3594 213.9063,129.6563 213.9063,129.9375 C213.9063,130.2188 214.0469,130.4688 214.2656,130.6406 C214.4219,130.75 214.6094,130.7813 215.0313,130.7813 L216.75,130.7813 L216.75,137.2969 L215.0313,137.2969 C214.5938,137.2969 214.4688,137.3125 214.3125,137.4219 C214.0625,137.5781 213.9063,137.8594 213.9063,138.1563 C213.9063,138.4063 214.0469,138.6719 214.2656,138.8281 C214.4219,138.9531 214.625,139 215.0313,139 L220.1719,139 C220.9219,139 221.2813,138.7188 221.2813,138.1563 C221.2813,137.875 221.1719,137.625 220.9375,137.4531 C220.7656,137.3281 220.625,137.2969 220.1719,137.2969 L218.4531,137.2969 L218.4531,130.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="101" x="231.5" y="138.8467">ByteArrayPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="203.5" x2="334.5" y1="150" y2="150"/><line style="stroke:#181818;stroke-width:0.5;" x1="203.5" x2="334.5" y1="158" y2="158"/></g><!--class GenericByteArrayPool--><g id="elem_GenericByteArrayPool"><rect fill="#F1F1F1" height="48" id="GenericByteArrayPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="191" x="82.5" y="226"/><ellipse cx="97.5" cy="242" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M99.8438,237.6719 C98.9063,237.2344 98.3125,237.0938 97.4375,237.0938 C94.8125,237.0938 92.8125,239.1719 92.8125,241.8906 L92.8125,243.0156 C92.8125,245.5938 94.9219,247.4844 97.8125,247.4844 C99.0313,247.4844 100.1875,247.1875 100.9375,246.6406 C101.5156,246.2344 101.8438,245.7813 101.8438,245.3906 C101.8438,244.9375 101.4531,244.5469 100.9844,244.5469 C100.7656,244.5469 100.5625,244.625 100.375,244.8125 C99.9219,245.2969 99.9219,245.2969 99.7344,245.3906 C99.3125,245.6563 98.625,245.7813 97.8594,245.7813 C95.8125,245.7813 94.5156,244.6875 94.5156,242.9844 L94.5156,241.8906 C94.5156,240.1094 95.7656,238.7969 97.5,238.7969 C98.0781,238.7969 98.6875,238.9531 99.1563,239.2031 C99.6406,239.4844 99.8125,239.7031 99.9063,240.1094 C99.9688,240.5156 100,240.6406 100.1406,240.7656 C100.2813,240.9063 100.5156,241.0156 100.7344,241.0156 C101,241.0156 101.2656,240.875 101.4375,240.6563 C101.5469,240.5 101.5781,240.3125 101.5781,239.8906 L101.5781,238.4688 C101.5781,238.0313 101.5625,237.9063 101.4688,237.75 C101.3125,237.4844 101.0313,237.3438 100.7344,237.3438 C100.4375,237.3438 100.2344,237.4375 100.0156,237.75 L99.8438,237.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="159" x="111.5" y="246.8467">GenericByteArrayPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="83.5" x2="272.5" y1="258" y2="258"/><line style="stroke:#181818;stroke-width:0.5;" x1="83.5" x2="272.5" y1="266" y2="266"/></g><!--reverse link Pool to ByteArrayPool--><g id="link_Pool_ByteArrayPool"><path codeLine="4" d="M269,76 C269,93.658 269,99.941 269,117.678 " fill="none" id="Pool-backto-ByteArrayPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="269,58,263,76,275,76,269,58" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link ByteArrayPool to GenericByteArrayPool--><g id="link_ByteArrayPool_GenericByteArrayPool"><path codeLine="5" d="M237.5294,179.6577 C222.3704,197.3161 213.249,207.9408 198.021,225.6784 " fill="none" id="ByteArrayPool-backto-GenericByteArrayPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="249.254,166,232.9768,175.7495,242.082,183.5659,249.254,166" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BasePool to GenericByteArrayPool--><g id="link_BasePool_GenericByteArrayPool"><path codeLine="6" d="M118.4704,179.6576 C133.6298,197.316 142.751,207.9408 157.979,225.6784 " fill="none" id="BasePool-backto-GenericByteArrayPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="106.7456,166,113.9178,183.5658,123.0229,175.7493,106.7456,166" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[Iyv9B2vMS4eiJWt8py-nSQeiINKiAagijEFAp2j9BKfBJ4vL0Cia0MKKecEHnU6AGGguG8I2JOskBfeu2W-Ym3qrBxKeCnbD7TGDk9K00000]--></g></svg>

<p>字节缓存池与内存块缓存池的机制是一样的，区别是内存块缓存池使用了1KB、2KB、4KB等一系列大小的内存块，而字节内存缓存池只有16KB大小的一种缓存块。一般作为一个临时内存来使用，使用完成后立马放回缓存池，</p>
<p><strong>使用场景：</strong></p>
<ul>
<li>网络请求数据从输入流中读数据到一个临时的buffer中，这个buffer就是从字节内存缓存池中拿到的；</li>
<li>图片缓存到磁盘中时，内存的输入流中先读取数据到一个buffer中，然后从buffer写入到磁盘的输出流，其中buffer也是从字节内存缓存池中拿到；</li>
</ul>
<h2 id="图片解码器"><a href="#图片解码器" class="headerlink" title="图片解码器"></a>图片解码器</h2><?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="567px" preserveAspectRatio="none" style="width:1034px;height:567px;background:#FFFFFF;" version="1.1" viewBox="0 0 1034 567" width="1034px" zoomAndPan="magnify"><defs/><g><!--class ImageDecoder--><g id="elem_ImageDecoder"><rect codeLine="1" fill="#F1F1F1" height="48" id="ImageDecoder" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="138" x="530" y="7"/><ellipse cx="545" cy="23" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M545.9531,19.7813 L547.6719,19.7813 C548.0625,19.7813 548.25,19.75 548.375,19.6719 C548.6406,19.5156 548.7813,19.2344 548.7813,18.9375 C548.7813,18.6719 548.6719,18.4063 548.4375,18.2344 C548.2656,18.125 548.125,18.0938 547.6719,18.0938 L542.5313,18.0938 C542.0938,18.0938 541.9688,18.1094 541.8125,18.2031 C541.5625,18.3594 541.4063,18.6563 541.4063,18.9375 C541.4063,19.2188 541.5469,19.4688 541.7656,19.6406 C541.9219,19.75 542.1094,19.7813 542.5313,19.7813 L544.25,19.7813 L544.25,26.2969 L542.5313,26.2969 C542.0938,26.2969 541.9688,26.3125 541.8125,26.4219 C541.5625,26.5781 541.4063,26.8594 541.4063,27.1563 C541.4063,27.4063 541.5469,27.6719 541.7656,27.8281 C541.9219,27.9531 542.125,28 542.5313,28 L547.6719,28 C548.4219,28 548.7813,27.7188 548.7813,27.1563 C548.7813,26.875 548.6719,26.625 548.4375,26.4531 C548.2656,26.3281 548.125,26.2969 547.6719,26.2969 L545.9531,26.2969 L545.9531,19.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="106" x="559" y="27.8467">ImageDecoder</text><line style="stroke:#181818;stroke-width:0.5;" x1="531" x2="667" y1="39" y2="39"/><line style="stroke:#181818;stroke-width:0.5;" x1="531" x2="667" y1="47" y2="47"/></g><!--class DefaultImageDecoder--><g id="elem_DefaultImageDecoder"><rect codeLine="3" fill="#F1F1F1" height="113.1875" id="DefaultImageDecoder" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="308" x="445" y="119"/><ellipse cx="515.75" cy="135" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M518.0938,130.6719 C517.1563,130.2344 516.5625,130.0938 515.6875,130.0938 C513.0625,130.0938 511.0625,132.1719 511.0625,134.8906 L511.0625,136.0156 C511.0625,138.5938 513.1719,140.4844 516.0625,140.4844 C517.2813,140.4844 518.4375,140.1875 519.1875,139.6406 C519.7656,139.2344 520.0938,138.7813 520.0938,138.3906 C520.0938,137.9375 519.7031,137.5469 519.2344,137.5469 C519.0156,137.5469 518.8125,137.625 518.625,137.8125 C518.1719,138.2969 518.1719,138.2969 517.9844,138.3906 C517.5625,138.6563 516.875,138.7813 516.1094,138.7813 C514.0625,138.7813 512.7656,137.6875 512.7656,135.9844 L512.7656,134.8906 C512.7656,133.1094 514.0156,131.7969 515.75,131.7969 C516.3281,131.7969 516.9375,131.9531 517.4063,132.2031 C517.8906,132.4844 518.0625,132.7031 518.1563,133.1094 C518.2188,133.5156 518.25,133.6406 518.3906,133.7656 C518.5313,133.9063 518.7656,134.0156 518.9844,134.0156 C519.25,134.0156 519.5156,133.875 519.6875,133.6563 C519.7969,133.5 519.8281,133.3125 519.8281,132.8906 L519.8281,131.4688 C519.8281,131.0313 519.8125,130.9063 519.7188,130.75 C519.5625,130.4844 519.2813,130.3438 518.9844,130.3438 C518.6875,130.3438 518.4844,130.4375 518.2656,130.75 L518.0938,130.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="158" x="536.25" y="139.8467">DefaultImageDecoder</text><line style="stroke:#181818;stroke-width:0.5;" x1="446" x2="752" y1="151" y2="151"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="275" x="451" y="167.9951">ImageDecoder mAnimatedGifDecoder</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="296" x="451" y="184.292">ImageDecoder mAnimatedWebPDecoder</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="266" x="451" y="200.5889">PlatformDecoder mPlatformDecoder</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="237" x="451" y="216.8857">ImageDecoder mDefaultDecoder</text><line style="stroke:#181818;stroke-width:0.5;" x1="446" x2="752" y1="224.1875" y2="224.1875"/></g><path d="M796.5,158 L796.5,166.5664 L688,212.0391 L796.5,174.5664 L796.5,183.1328 A0,0 0 0 0 796.5,183.1328 L1027.5,183.1328 A0,0 0 0 0 1027.5,183.1328 L1027.5,168 L1017.5,158 L796.5,158 A0,0 0 0 0 796.5,158 " fill="#FEFFDD" style="stroke:#181818;stroke-width:0.5;"/><path d="M1017.5,158 L1017.5,168 L1027.5,168 L1017.5,158 " fill="#FEFFDD" style="stroke:#181818;stroke-width:0.5;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="210" x="802.5" y="175.0669">&#20869;&#37096;&#31867;&#65292;&#26681;&#25454;&#22270;&#29255;&#26684;&#24335;&#36873;&#25321;Decoder</text><!--class PlatformDecoder--><g id="elem_PlatformDecoder"><rect codeLine="13" fill="#F1F1F1" height="48" id="PlatformDecoder" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="153" x="248.5" y="151.5"/><ellipse cx="263.5" cy="167.5" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M264.4531,164.2813 L266.1719,164.2813 C266.5625,164.2813 266.75,164.25 266.875,164.1719 C267.1406,164.0156 267.2813,163.7344 267.2813,163.4375 C267.2813,163.1719 267.1719,162.9063 266.9375,162.7344 C266.7656,162.625 266.625,162.5938 266.1719,162.5938 L261.0313,162.5938 C260.5938,162.5938 260.4688,162.6094 260.3125,162.7031 C260.0625,162.8594 259.9063,163.1563 259.9063,163.4375 C259.9063,163.7188 260.0469,163.9688 260.2656,164.1406 C260.4219,164.25 260.6094,164.2813 261.0313,164.2813 L262.75,164.2813 L262.75,170.7969 L261.0313,170.7969 C260.5938,170.7969 260.4688,170.8125 260.3125,170.9219 C260.0625,171.0781 259.9063,171.3594 259.9063,171.6563 C259.9063,171.9063 260.0469,172.1719 260.2656,172.3281 C260.4219,172.4531 260.625,172.5 261.0313,172.5 L266.1719,172.5 C266.9219,172.5 267.2813,172.2188 267.2813,171.6563 C267.2813,171.375 267.1719,171.125 266.9375,170.9531 C266.7656,170.8281 266.625,170.7969 266.1719,170.7969 L264.4531,170.7969 L264.4531,164.2813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="121" x="277.5" y="172.3467">PlatformDecoder</text><line style="stroke:#181818;stroke-width:0.5;" x1="249.5" x2="400.5" y1="183.5" y2="183.5"/><line style="stroke:#181818;stroke-width:0.5;" x1="249.5" x2="400.5" y1="191.5" y2="191.5"/></g><!--class DefaultDecoder--><g id="elem_DefaultDecoder"><rect codeLine="14" fill="#F1F1F1" height="48" id="DefaultDecoder" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="145" x="70.5" y="296"/><ellipse cx="85.5" cy="312" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M87.5781,313.8125 L87.9688,314.7969 L87.5781,314.7969 C87.125,314.7969 87.0156,314.8125 86.8594,314.9219 C86.6094,315.0781 86.4531,315.3594 86.4531,315.6563 C86.4531,315.9219 86.5938,316.1719 86.8125,316.3281 C86.9531,316.4531 87.1563,316.5 87.5781,316.5 L89.9375,316.5 C90.2969,316.5 90.5156,316.4688 90.6563,316.375 C90.9063,316.2344 91.0625,315.9375 91.0625,315.6563 C91.0625,315.375 90.9219,315.125 90.7031,314.9688 C90.5313,314.8281 90.375,314.7969 89.9063,314.7969 L86.5156,306.5938 L82.8438,306.5938 C82.3906,306.5938 82.2656,306.6094 82.1094,306.7031 C81.8594,306.875 81.7031,307.1563 81.7031,307.4375 C81.7031,307.7188 81.8438,307.9688 82.0625,308.1406 C82.2344,308.25 82.4063,308.2813 82.8438,308.2813 L83.9219,308.2813 L81.2813,314.7969 C80.8594,314.7969 80.7031,314.8125 80.5469,314.9219 C80.2969,315.0781 80.1406,315.3594 80.1406,315.6563 C80.1406,316.2188 80.5156,316.5 81.2656,316.5 L83.5313,316.5 C83.8906,316.5 84.1094,316.4688 84.2344,316.375 C84.5,316.2344 84.6406,315.9375 84.6406,315.6563 C84.6406,315.375 84.5156,315.125 84.2969,314.9531 C84.125,314.8281 83.9844,314.7969 83.5313,314.7969 L83.1406,314.7969 L83.5313,313.8125 L87.5781,313.8125 Z M86.875,312.1094 L84.2031,312.1094 L85.5469,308.8438 L86.875,312.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="113" x="99.5" y="316.8467">DefaultDecoder</text><line style="stroke:#181818;stroke-width:0.5;" x1="71.5" x2="214.5" y1="328" y2="328"/><line style="stroke:#181818;stroke-width:0.5;" x1="71.5" x2="214.5" y1="336" y2="336"/></g><!--class OreoDecoder--><g id="elem_OreoDecoder"><rect fill="#F1F1F1" height="48" id="OreoDecoder" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="128" x="158" y="404"/><ellipse cx="173" cy="420" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M175.3438,415.6719 C174.4063,415.2344 173.8125,415.0938 172.9375,415.0938 C170.3125,415.0938 168.3125,417.1719 168.3125,419.8906 L168.3125,421.0156 C168.3125,423.5938 170.4219,425.4844 173.3125,425.4844 C174.5313,425.4844 175.6875,425.1875 176.4375,424.6406 C177.0156,424.2344 177.3438,423.7813 177.3438,423.3906 C177.3438,422.9375 176.9531,422.5469 176.4844,422.5469 C176.2656,422.5469 176.0625,422.625 175.875,422.8125 C175.4219,423.2969 175.4219,423.2969 175.2344,423.3906 C174.8125,423.6563 174.125,423.7813 173.3594,423.7813 C171.3125,423.7813 170.0156,422.6875 170.0156,420.9844 L170.0156,419.8906 C170.0156,418.1094 171.2656,416.7969 173,416.7969 C173.5781,416.7969 174.1875,416.9531 174.6563,417.2031 C175.1406,417.4844 175.3125,417.7031 175.4063,418.1094 C175.4688,418.5156 175.5,418.6406 175.6406,418.7656 C175.7813,418.9063 176.0156,419.0156 176.2344,419.0156 C176.5,419.0156 176.7656,418.875 176.9375,418.6563 C177.0469,418.5 177.0781,418.3125 177.0781,417.8906 L177.0781,416.4688 C177.0781,416.0313 177.0625,415.9063 176.9688,415.75 C176.8125,415.4844 176.5313,415.3438 176.2344,415.3438 C175.9375,415.3438 175.7344,415.4375 175.5156,415.75 L175.3438,415.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="96" x="187" y="424.8467">OreoDecoder</text><line style="stroke:#181818;stroke-width:0.5;" x1="159" x2="285" y1="436" y2="436"/><line style="stroke:#181818;stroke-width:0.5;" x1="159" x2="285" y1="444" y2="444"/></g><!--class ArtDecoder--><g id="elem_ArtDecoder"><rect fill="#F1F1F1" height="48" id="ArtDecoder" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="116" x="7" y="404"/><ellipse cx="22" cy="420" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M24.3438,415.6719 C23.4063,415.2344 22.8125,415.0938 21.9375,415.0938 C19.3125,415.0938 17.3125,417.1719 17.3125,419.8906 L17.3125,421.0156 C17.3125,423.5938 19.4219,425.4844 22.3125,425.4844 C23.5313,425.4844 24.6875,425.1875 25.4375,424.6406 C26.0156,424.2344 26.3438,423.7813 26.3438,423.3906 C26.3438,422.9375 25.9531,422.5469 25.4844,422.5469 C25.2656,422.5469 25.0625,422.625 24.875,422.8125 C24.4219,423.2969 24.4219,423.2969 24.2344,423.3906 C23.8125,423.6563 23.125,423.7813 22.3594,423.7813 C20.3125,423.7813 19.0156,422.6875 19.0156,420.9844 L19.0156,419.8906 C19.0156,418.1094 20.2656,416.7969 22,416.7969 C22.5781,416.7969 23.1875,416.9531 23.6563,417.2031 C24.1406,417.4844 24.3125,417.7031 24.4063,418.1094 C24.4688,418.5156 24.5,418.6406 24.6406,418.7656 C24.7813,418.9063 25.0156,419.0156 25.2344,419.0156 C25.5,419.0156 25.7656,418.875 25.9375,418.6563 C26.0469,418.5 26.0781,418.3125 26.0781,417.8906 L26.0781,416.4688 C26.0781,416.0313 26.0625,415.9063 25.9688,415.75 C25.8125,415.4844 25.5313,415.3438 25.2344,415.3438 C24.9375,415.3438 24.7344,415.4375 24.5156,415.75 L24.3438,415.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="84" x="36" y="424.8467">ArtDecoder</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="122" y1="436" y2="436"/><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="122" y1="444" y2="444"/></g><!--class PlatformDecoderFactory--><g id="elem_PlatformDecoderFactory"><rect fill="#F1F1F1" height="48" id="PlatformDecoderFactory" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="210" x="219" y="512"/><ellipse cx="234" cy="528" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M236.3438,523.6719 C235.4063,523.2344 234.8125,523.0938 233.9375,523.0938 C231.3125,523.0938 229.3125,525.1719 229.3125,527.8906 L229.3125,529.0156 C229.3125,531.5938 231.4219,533.4844 234.3125,533.4844 C235.5313,533.4844 236.6875,533.1875 237.4375,532.6406 C238.0156,532.2344 238.3438,531.7813 238.3438,531.3906 C238.3438,530.9375 237.9531,530.5469 237.4844,530.5469 C237.2656,530.5469 237.0625,530.625 236.875,530.8125 C236.4219,531.2969 236.4219,531.2969 236.2344,531.3906 C235.8125,531.6563 235.125,531.7813 234.3594,531.7813 C232.3125,531.7813 231.0156,530.6875 231.0156,528.9844 L231.0156,527.8906 C231.0156,526.1094 232.2656,524.7969 234,524.7969 C234.5781,524.7969 235.1875,524.9531 235.6563,525.2031 C236.1406,525.4844 236.3125,525.7031 236.4063,526.1094 C236.4688,526.5156 236.5,526.6406 236.6406,526.7656 C236.7813,526.9063 237.0156,527.0156 237.2344,527.0156 C237.5,527.0156 237.7656,526.875 237.9375,526.6563 C238.0469,526.5 238.0781,526.3125 238.0781,525.8906 L238.0781,524.4688 C238.0781,524.0313 238.0625,523.9063 237.9688,523.75 C237.8125,523.4844 237.5313,523.3438 237.2344,523.3438 C236.9375,523.3438 236.7344,523.4375 236.5156,523.75 L236.3438,523.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="178" x="248" y="532.8467">PlatformDecoderFactory</text><line style="stroke:#181818;stroke-width:0.5;" x1="220" x2="428" y1="544" y2="544"/><line style="stroke:#181818;stroke-width:0.5;" x1="220" x2="428" y1="552" y2="552"/></g><!--class GingerbreadPurgeableDecoder--><g id="elem_GingerbreadPurgeableDecoder"><rect fill="#F1F1F1" height="48" id="GingerbreadPurgeableDecoder" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="255" x="567.5" y="404"/><ellipse cx="582.5" cy="420" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M584.8438,415.6719 C583.9063,415.2344 583.3125,415.0938 582.4375,415.0938 C579.8125,415.0938 577.8125,417.1719 577.8125,419.8906 L577.8125,421.0156 C577.8125,423.5938 579.9219,425.4844 582.8125,425.4844 C584.0313,425.4844 585.1875,425.1875 585.9375,424.6406 C586.5156,424.2344 586.8438,423.7813 586.8438,423.3906 C586.8438,422.9375 586.4531,422.5469 585.9844,422.5469 C585.7656,422.5469 585.5625,422.625 585.375,422.8125 C584.9219,423.2969 584.9219,423.2969 584.7344,423.3906 C584.3125,423.6563 583.625,423.7813 582.8594,423.7813 C580.8125,423.7813 579.5156,422.6875 579.5156,420.9844 L579.5156,419.8906 C579.5156,418.1094 580.7656,416.7969 582.5,416.7969 C583.0781,416.7969 583.6875,416.9531 584.1563,417.2031 C584.6406,417.4844 584.8125,417.7031 584.9063,418.1094 C584.9688,418.5156 585,418.6406 585.1406,418.7656 C585.2813,418.9063 585.5156,419.0156 585.7344,419.0156 C586,419.0156 586.2656,418.875 586.4375,418.6563 C586.5469,418.5 586.5781,418.3125 586.5781,417.8906 L586.5781,416.4688 C586.5781,416.0313 586.5625,415.9063 586.4688,415.75 C586.3125,415.4844 586.0313,415.3438 585.7344,415.3438 C585.4375,415.3438 585.2344,415.4375 585.0156,415.75 L584.8438,415.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="223" x="596.5" y="424.8467">GingerbreadPurgeableDecoder</text><line style="stroke:#181818;stroke-width:0.5;" x1="568.5" x2="821.5" y1="436" y2="436"/><line style="stroke:#181818;stroke-width:0.5;" x1="568.5" x2="821.5" y1="444" y2="444"/></g><!--class KitKatPurgeableDecoder--><g id="elem_KitKatPurgeableDecoder"><rect fill="#F1F1F1" height="48" id="KitKatPurgeableDecoder" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="211" x="321.5" y="404"/><ellipse cx="336.5" cy="420" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M338.8438,415.6719 C337.9063,415.2344 337.3125,415.0938 336.4375,415.0938 C333.8125,415.0938 331.8125,417.1719 331.8125,419.8906 L331.8125,421.0156 C331.8125,423.5938 333.9219,425.4844 336.8125,425.4844 C338.0313,425.4844 339.1875,425.1875 339.9375,424.6406 C340.5156,424.2344 340.8438,423.7813 340.8438,423.3906 C340.8438,422.9375 340.4531,422.5469 339.9844,422.5469 C339.7656,422.5469 339.5625,422.625 339.375,422.8125 C338.9219,423.2969 338.9219,423.2969 338.7344,423.3906 C338.3125,423.6563 337.625,423.7813 336.8594,423.7813 C334.8125,423.7813 333.5156,422.6875 333.5156,420.9844 L333.5156,419.8906 C333.5156,418.1094 334.7656,416.7969 336.5,416.7969 C337.0781,416.7969 337.6875,416.9531 338.1563,417.2031 C338.6406,417.4844 338.8125,417.7031 338.9063,418.1094 C338.9688,418.5156 339,418.6406 339.1406,418.7656 C339.2813,418.9063 339.5156,419.0156 339.7344,419.0156 C340,419.0156 340.2656,418.875 340.4375,418.6563 C340.5469,418.5 340.5781,418.3125 340.5781,417.8906 L340.5781,416.4688 C340.5781,416.0313 340.5625,415.9063 340.4688,415.75 C340.3125,415.4844 340.0313,415.3438 339.7344,415.3438 C339.4375,415.3438 339.2344,415.4375 339.0156,415.75 L338.8438,415.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="179" x="350.5" y="424.8467">KitKatPurgeableDecoder</text><line style="stroke:#181818;stroke-width:0.5;" x1="322.5" x2="531.5" y1="436" y2="436"/><line style="stroke:#181818;stroke-width:0.5;" x1="322.5" x2="531.5" y1="444" y2="444"/></g><!--class DalvikPurgeableDecoder--><g id="elem_DalvikPurgeableDecoder"><rect codeLine="23" fill="#F1F1F1" height="48" id="DalvikPurgeableDecoder" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="209" x="402.5" y="296"/><ellipse cx="417.5" cy="312" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M419.5781,313.8125 L419.9688,314.7969 L419.5781,314.7969 C419.125,314.7969 419.0156,314.8125 418.8594,314.9219 C418.6094,315.0781 418.4531,315.3594 418.4531,315.6563 C418.4531,315.9219 418.5938,316.1719 418.8125,316.3281 C418.9531,316.4531 419.1563,316.5 419.5781,316.5 L421.9375,316.5 C422.2969,316.5 422.5156,316.4688 422.6563,316.375 C422.9063,316.2344 423.0625,315.9375 423.0625,315.6563 C423.0625,315.375 422.9219,315.125 422.7031,314.9688 C422.5313,314.8281 422.375,314.7969 421.9063,314.7969 L418.5156,306.5938 L414.8438,306.5938 C414.3906,306.5938 414.2656,306.6094 414.1094,306.7031 C413.8594,306.875 413.7031,307.1563 413.7031,307.4375 C413.7031,307.7188 413.8438,307.9688 414.0625,308.1406 C414.2344,308.25 414.4063,308.2813 414.8438,308.2813 L415.9219,308.2813 L413.2813,314.7969 C412.8594,314.7969 412.7031,314.8125 412.5469,314.9219 C412.2969,315.0781 412.1406,315.3594 412.1406,315.6563 C412.1406,316.2188 412.5156,316.5 413.2656,316.5 L415.5313,316.5 C415.8906,316.5 416.1094,316.4688 416.2344,316.375 C416.5,316.2344 416.6406,315.9375 416.6406,315.6563 C416.6406,315.375 416.5156,315.125 416.2969,314.9531 C416.125,314.8281 415.9844,314.7969 415.5313,314.7969 L415.1406,314.7969 L415.5313,313.8125 L419.5781,313.8125 Z M418.875,312.1094 L416.2031,312.1094 L417.5469,308.8438 L418.875,312.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="177" x="431.5" y="316.8467">DalvikPurgeableDecoder</text><line style="stroke:#181818;stroke-width:0.5;" x1="403.5" x2="610.5" y1="328" y2="328"/><line style="stroke:#181818;stroke-width:0.5;" x1="403.5" x2="610.5" y1="336" y2="336"/></g><!--class BitmapPool--><g id="elem_BitmapPool"><rect fill="#F1F1F1" height="48" id="BitmapPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="116" x="251" y="296"/><ellipse cx="266" cy="312" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M268.3438,307.6719 C267.4063,307.2344 266.8125,307.0938 265.9375,307.0938 C263.3125,307.0938 261.3125,309.1719 261.3125,311.8906 L261.3125,313.0156 C261.3125,315.5938 263.4219,317.4844 266.3125,317.4844 C267.5313,317.4844 268.6875,317.1875 269.4375,316.6406 C270.0156,316.2344 270.3438,315.7813 270.3438,315.3906 C270.3438,314.9375 269.9531,314.5469 269.4844,314.5469 C269.2656,314.5469 269.0625,314.625 268.875,314.8125 C268.4219,315.2969 268.4219,315.2969 268.2344,315.3906 C267.8125,315.6563 267.125,315.7813 266.3594,315.7813 C264.3125,315.7813 263.0156,314.6875 263.0156,312.9844 L263.0156,311.8906 C263.0156,310.1094 264.2656,308.7969 266,308.7969 C266.5781,308.7969 267.1875,308.9531 267.6563,309.2031 C268.1406,309.4844 268.3125,309.7031 268.4063,310.1094 C268.4688,310.5156 268.5,310.6406 268.6406,310.7656 C268.7813,310.9063 269.0156,311.0156 269.2344,311.0156 C269.5,311.0156 269.7656,310.875 269.9375,310.6563 C270.0469,310.5 270.0781,310.3125 270.0781,309.8906 L270.0781,308.4688 C270.0781,308.0313 270.0625,307.9063 269.9688,307.75 C269.8125,307.4844 269.5313,307.3438 269.2344,307.3438 C268.9375,307.3438 268.7344,307.4375 268.5156,307.75 L268.3438,307.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="84" x="280" y="316.8467">BitmapPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="252" x2="366" y1="328" y2="328"/><line style="stroke:#181818;stroke-width:0.5;" x1="252" x2="366" y1="336" y2="336"/></g><!--reverse link ImageDecoder to DefaultImageDecoder--><g id="link_ImageDecoder_DefaultImageDecoder"><path codeLine="2" d="M599,73.212 C599,89.38 599,93.724 599,114.707 " fill="none" id="ImageDecoder-backto-DefaultImageDecoder" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="599,55.212,593,73.212,605,73.212,599,55.212" style="stroke:#181818;stroke-width:1.0;"/></g><!--link PlatformDecoder to DefaultImageDecoder--><g id="link_PlatformDecoder_DefaultImageDecoder"><path codeLine="15" d="M401.536,192.152 C415.581,194.15 418.182,195.5 432,195.5 " fill="none" id="PlatformDecoder-to-DefaultImageDecoder" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="444,195.5,438,191.5,432,195.5,438,199.5,444,195.5" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link PlatformDecoder to DefaultDecoder--><g id="link_PlatformDecoder_DefaultDecoder"><path codeLine="16" d="M281.1804,210.8088 C247.3364,237.3078 206.473,269.303 172.634,295.798 " fill="none" id="PlatformDecoder-backto-DefaultDecoder" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="295.353,199.712,277.4815,206.0846,284.8794,215.533,295.353,199.712" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DefaultDecoder to OreoDecoder--><g id="link_DefaultDecoder_OreoDecoder"><path codeLine="17" d="M170.8983,358.4327 C184.0583,376.0907 191.399,385.941 204.619,403.678 " fill="none" id="DefaultDecoder-backto-OreoDecoder" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="160.142,344,166.0874,362.0181,175.7092,354.8473,160.142,344" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DefaultDecoder to ArtDecoder--><g id="link_DefaultDecoder_ArtDecoder"><path codeLine="18" d="M115.4071,358.4981 C102.4141,376.1561 95.2134,385.941 82.1612,403.678 " fill="none" id="DefaultDecoder-backto-ArtDecoder" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="126.075,344,110.5744,354.9421,120.2398,362.0541,126.075,344" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link OreoDecoder to PlatformDecoderFactory--><g id="link_OreoDecoder_PlatformDecoderFactory"><path codeLine="19" d="M248.2923,456.3234 C265.2843,473.9818 284.49,493.9408 301.558,511.6784 " fill="none" id="OreoDecoder-backto-PlatformDecoderFactory" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="244.132,452,247.4901,461.2587,247.5989,455.6029,253.2547,455.7116,244.132,452" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link ArtDecoder to PlatformDecoderFactory--><g id="link_ArtDecoder_PlatformDecoderFactory"><path codeLine="20" d="M126.7519,454.2727 C170.0459,471.992 224.085,494.1083 267.464,511.8617 " fill="none" id="ArtDecoder-backto-PlatformDecoderFactory" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="121.199,452,128.0132,459.111,125.8264,453.8939,131.0435,451.7071,121.199,452" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link GingerbreadPurgeableDecoder to PlatformDecoderFactory--><g id="link_GingerbreadPurgeableDecoder_PlatformDecoderFactory"><path codeLine="21" d="M608.7299,453.6484 C546.6069,471.3981 466.827,494.1922 404.664,511.9531 " fill="none" id="GingerbreadPurgeableDecoder-backto-PlatformDecoderFactory" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="614.499,452,604.7464,450.6264,609.6914,453.3736,606.9442,458.3186,614.499,452" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link KitKatPurgeableDecoder to PlatformDecoderFactory--><g id="link_KitKatPurgeableDecoder_PlatformDecoderFactory"><path codeLine="22" d="M400.4696,456.3031 C383.3106,473.9615 363.897,493.9408 346.662,511.6784 " fill="none" id="KitKatPurgeableDecoder-backto-PlatformDecoderFactory" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="404.651,452,395.5103,455.667,401.1665,455.5859,401.2477,461.2421,404.651,452" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link PlatformDecoder to DalvikPurgeableDecoder--><g id="link_PlatformDecoder_DalvikPurgeableDecoder"><path codeLine="24" d="M368.8196,210.8088 C402.6636,237.3078 443.527,269.303 477.366,295.798 " fill="none" id="PlatformDecoder-backto-DalvikPurgeableDecoder" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="354.647,199.712,365.1206,215.533,372.5185,206.0846,354.647,199.712" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DalvikPurgeableDecoder to GingerbreadPurgeableDecoder--><g id="link_DalvikPurgeableDecoder_GingerbreadPurgeableDecoder"><path codeLine="25" d="M563.4724,352.8406 C594.8984,370.5596 622.475,386.108 653.962,403.862 " fill="none" id="DalvikPurgeableDecoder-backto-GingerbreadPurgeableDecoder" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="547.793,344,560.5256,358.067,566.4193,347.6141,547.793,344" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DalvikPurgeableDecoder to KitKatPurgeableDecoder--><g id="link_DalvikPurgeableDecoder_KitKatPurgeableDecoder"><path codeLine="26" d="M478.7976,358.3673 C465.4706,376.0253 457.988,385.941 444.601,403.678 " fill="none" id="DalvikPurgeableDecoder-backto-KitKatPurgeableDecoder" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="489.641,344,474.0085,354.7528,483.5867,361.9818,489.641,344" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DefaultDecoder to BitmapPool--><g id="link_DefaultDecoder_BitmapPool"><path codeLine="27" d="M227.625,320 C239.297,320 238.969,320 250.641,320 " fill="none" id="DefaultDecoder-backto-BitmapPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="215.625,320,221.625,324,227.625,320,221.625,316,215.625,320" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[ZP71IiD048RlUOez5_O5YWYLOf4UpCtp99cDYvjisKm4KK4GbQBY0tZfKI-2Hp7uDatfgQzWYqr9jaditdRc-__vTrR6X4Q0Z-meWX3xwEi0ZLE-iBqhpbaV1QIAAfIl84dgEkpIOSjJAKMzM4P060oaA0oQeHFqt3BbAY2XJRG1hKADrJfN0LmxiIPaHeQdnBIeYztjsgALw_J-RdxxDllyNcHF-UGhV_wOllxCnW_v99jcB_ERSVxuNl0O1smrnd7aPh5sKl0ICk0JgwolwDR7if_VuGe5yIrlcoj_dJMXWXmRr6tzdg664OVBbsXpmNWwuliLdrPmLyE1Z4Cqda48tDI429x2dOH3IKEWBOszV53dykm_v_KQwzdwyf-aBNsRhY6yzJCTpWuaHJ1ojLQ_]--></g></svg>

<h3 id="Bitmap内存占用"><a href="#Bitmap内存占用" class="headerlink" title="Bitmap内存占用"></a>Bitmap内存占用</h3><ul>
<li>Android 2.3.3 (API level 10)以及更早的Android版本中，Bitmap的像素数据保存在native内存中，像素数据内存的回收则在finalize()中进行回收，存在很大的不确定性，很容易导致OOM的发生；</li>
<li>从Android 3.0 (API level 11) 到Android 7.1 (API level 25)，像素数据存放在Java Heap中，跟Bitmap对象一起回收。但由于图片是内存消耗大户，所以也很容易导致OOM，以及频繁的GC导致内存抖动问题。</li>
<li>在Android 8.0 (API level 26)以及更高的版本中，像素数据保存在native heap中。通过一个辅助类<code>NativeAllocationRegistry</code>来实现native内存的回收。</li>
</ul>
<p>Android5.0及以上的版本，Fresco采用标准的Bitmap解码，通过BitmapFactoty.decodeXXX系列函数进行位图解码，pixel数据内存的分配完全由Android系统决定，可以参考<a href="/posts/68833f9e.html" title="Bitmap内存分配以及回收">Bitmap内存分配以及回收</a>，所以这里就不介绍了。</p>
<p>本节重点介绍在Android5.0以下的系统上，Fresco是如何把pixel数据放在了共享内存中的？</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//imagepipeline-native/src/main/java/com/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder.java</span></span><br><span class="line">  <span class="keyword">public</span> CloseableReference&lt;Bitmap&gt; <span class="title function_">decodeJPEGFromEncodedImageWithColorSpace</span><span class="params">(</span></span><br><span class="line"><span class="params">      <span class="keyword">final</span> EncodedImage encodedImage,</span></span><br><span class="line"><span class="params">      Bitmap.Config bitmapConfig,</span></span><br><span class="line"><span class="params">      <span class="meta">@Nullable</span> Rect regionToDecode,</span></span><br><span class="line"><span class="params">      <span class="type">int</span> length,</span></span><br><span class="line"><span class="params">      <span class="meta">@Nullable</span> <span class="keyword">final</span> ColorSpace colorSpace)</span> &#123;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//设置解码配置信息，函数实现见下方代码</span></span><br><span class="line">    BitmapFactory.<span class="type">Options</span> <span class="variable">options</span> <span class="operator">=</span></span><br><span class="line">        getBitmapFactoryOptions(encodedImage.getSampleSize(), bitmapConfig); </span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) &#123;</span><br><span class="line">      OreoUtils.setColorSpace(options, colorSpace);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">final</span> CloseableReference&lt;PooledByteBuffer&gt; bytesRef = encodedImage.getByteBufferRef();</span><br><span class="line">    Preconditions.checkNotNull(bytesRef);</span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">      <span class="comment">//最终会调用BitmapFactory.decodeByteArray或BitmapFactory.decodeFileDescriptor来解码位图</span></span><br><span class="line">      <span class="type">Bitmap</span> <span class="variable">bitmap</span> <span class="operator">=</span> decodeJPEGByteArrayAsPurgeable(bytesRef, length, options);</span><br><span class="line"></span><br><span class="line">      <span class="comment">//通过jni最终调用framework中的AndroidBitmap_lockPixels（c++函数），待会儿再介绍作用</span></span><br><span class="line">      <span class="keyword">return</span> pinBitmap(bitmap); </span><br><span class="line">    &#125; <span class="keyword">finally</span> &#123;</span><br><span class="line">      CloseableReference.closeSafely(bytesRef);</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="keyword">public</span> <span class="keyword">static</span> BitmapFactory.Options <span class="title function_">getBitmapFactoryOptions</span><span class="params">(</span></span><br><span class="line"><span class="params">      <span class="type">int</span> sampleSize, Bitmap.Config bitmapConfig)</span> &#123;</span><br><span class="line">    BitmapFactory.<span class="type">Options</span> <span class="variable">options</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">BitmapFactory</span>.Options();</span><br><span class="line">    options.inDither = <span class="literal">true</span>; <span class="comment">// known to improve picture quality at low cost</span></span><br><span class="line">    options.inPreferredConfig = bitmapConfig;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// Decode the image into a &#x27;purgeable&#x27; bitmap that lives on the ashmem heap</span></span><br><span class="line">    <span class="comment">//BitmapFactory.cpp中doDecode时会读取这个配置，从而使用共享内存</span></span><br><span class="line">    options.inPurgeable = <span class="literal">true</span>;</span><br><span class="line">    <span class="comment">// Enable copy of of bitmap to enable purgeable decoding by filedescriptor</span></span><br><span class="line">    options.inInputShareable = <span class="literal">true</span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// Sample size should ONLY be different than 1 when downsampling is enabled in the pipeline</span></span><br><span class="line">    options.inSampleSize = sampleSize;</span><br><span class="line">    options.inMutable = <span class="literal">true</span>; <span class="comment">// no known perf difference; allows postprocessing to work</span></span><br><span class="line">    <span class="keyword">return</span> options;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<p>继续看以下android framework 中bitmap解码的实现：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//android-4.4.4_r1\frameworks\base\core\jni\android\graphics\BitmapFactory.cpp</span></span><br><span class="line"><span class="function"><span class="type">static</span> jobject <span class="title">doDecode</span><span class="params">(JNIEnv* env, SkStreamRewindable* stream, jobject padding,</span></span></span><br><span class="line"><span class="params"><span class="function">        jobject options, <span class="type">bool</span> allowPurgeable, <span class="type">bool</span> forcePurgeable = <span class="literal">false</span>)</span> </span>&#123;</span><br><span class="line">    ...... <span class="comment">//代码省略</span></span><br><span class="line">    <span class="type">bool</span> isPurgeable = forcePurgeable || (allowPurgeable &amp;&amp; <span class="built_in">optionsPurgeable</span>(env, options));</span><br><span class="line">    ......</span><br><span class="line">    <span class="type">const</span> <span class="type">bool</span> willScale = scale != <span class="number">1.0f</span>;</span><br><span class="line">    isPurgeable &amp;= !willScale;  <span class="comment">//如果配置了按比例缩放，则isPurgeable不生效</span></span><br><span class="line">    ......</span><br><span class="line">    <span class="comment">//如果配置了isPurgeable，将会使用kDecodeBounds_Mode解码模式，即只解析长宽等信息，不会申请piexel内存</span></span><br><span class="line">    SkImageDecoder::Mode decodeMode = isPurgeable ? SkImageDecoder::kDecodeBounds_Mode : mode;</span><br><span class="line"></span><br><span class="line">    <span class="function">JavaPixelAllocator <span class="title">javaAllocator</span><span class="params">(env)</span></span>;</span><br><span class="line">    <span class="function">RecyclingPixelAllocator <span class="title">recyclingAllocator</span><span class="params">(outputBitmap-&gt;pixelRef(), existingBufferSize)</span></span>;</span><br><span class="line">    <span class="function">ScaleCheckingAllocator <span class="title">scaleCheckingAllocator</span><span class="params">(scale, existingBufferSize)</span></span>;</span><br><span class="line">    SkBitmap::Allocator* outputAllocator = (javaBitmap != <span class="literal">NULL</span>) ?</span><br><span class="line">            (SkBitmap::Allocator*)&amp;recyclingAllocator : (SkBitmap::Allocator*)&amp;javaAllocator;</span><br><span class="line">    <span class="keyword">if</span> (decodeMode != SkImageDecoder::kDecodeBounds_Mode) &#123;</span><br><span class="line">        <span class="comment">//isPurgeable为true时，不会走入这个if判断，所以decoder不会设置allocator</span></span><br><span class="line">        <span class="keyword">if</span> (!willScale) &#123;</span><br><span class="line">            <span class="comment">// If the java allocator is being used to allocate the pixel memory, the decoder</span></span><br><span class="line">            <span class="comment">// need not write zeroes, since the memory is initialized to 0.</span></span><br><span class="line">            decoder-&gt;<span class="built_in">setSkipWritingZeroes</span>(outputAllocator == &amp;javaAllocator);</span><br><span class="line">            decoder-&gt;<span class="built_in">setAllocator</span>(outputAllocator);</span><br><span class="line">        &#125; <span class="keyword">else</span> <span class="keyword">if</span> (javaBitmap != <span class="literal">NULL</span>) &#123;</span><br><span class="line">            <span class="comment">// check for eventual scaled bounds at allocation time, so we don&#x27;t decode the bitmap</span></span><br><span class="line">            <span class="comment">// only to find the scaled result too large to fit in the allocation</span></span><br><span class="line">            decoder-&gt;<span class="built_in">setAllocator</span>(&amp;scaleCheckingAllocator);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    ......</span><br><span class="line">    SkBitmap decodingBitmap;</span><br><span class="line">    <span class="comment">//使用SkImageDecoder::kDecodeBounds_Mode模式进行解码，所以decodingBitmap中没有pixel数据</span></span><br><span class="line">    <span class="keyword">if</span> (!decoder-&gt;<span class="built_in">decode</span>(stream, &amp;decodingBitmap, prefConfig, decodeMode)) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="built_in">nullObjectReturn</span>(<span class="string">&quot;decoder-&gt;decode returned false&quot;</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    ......</span><br><span class="line">    <span class="comment">// if we&#x27;re in justBounds mode, return now (skip the java bitmap)</span></span><br><span class="line">    <span class="comment">//此处并没有使用decodeMode来判断，所以不会返回，还会继续执行后面的代码</span></span><br><span class="line">    <span class="keyword">if</span> (mode == SkImageDecoder::kDecodeBounds_Mode) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    ......</span><br><span class="line">    SkPixelRef* pr;</span><br><span class="line">    <span class="keyword">if</span> (isPurgeable) &#123;</span><br><span class="line">        <span class="comment">//installPixelRef函数实现见下文</span></span><br><span class="line">        pr = <span class="built_in">installPixelRef</span>(outputBitmap, stream, sampleSize, doDither);</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="comment">// if we get here, we&#x27;re in kDecodePixels_Mode and will therefore</span></span><br><span class="line">        <span class="comment">// already have a pixelref installed.</span></span><br><span class="line">        pr = outputBitmap-&gt;<span class="built_in">pixelRef</span>();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span> (pr == <span class="literal">NULL</span>) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="built_in">nullObjectReturn</span>(<span class="string">&quot;Got null SkPixelRef&quot;</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    ......</span><br><span class="line">    <span class="comment">// now create the java bitmap</span></span><br><span class="line">    <span class="keyword">return</span> GraphicsJNI::<span class="built_in">createBitmap</span>(env, outputBitmap, javaAllocator.<span class="built_in">getStorageObj</span>(),</span><br><span class="line">            bitmapCreateFlags, ninePatchChunk, layoutBounds, <span class="number">-1</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">static</span> SkPixelRef* <span class="title">installPixelRef</span><span class="params">(SkBitmap* bitmap, SkStreamRewindable* stream,</span></span></span><br><span class="line"><span class="params"><span class="function">        <span class="type">int</span> sampleSize, <span class="type">bool</span> ditherImage)</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    SkImageInfo bitmapInfo;</span><br><span class="line">    <span class="keyword">if</span> (!bitmap-&gt;<span class="built_in">asImageInfo</span>(&amp;bitmapInfo)) &#123;</span><br><span class="line">        <span class="built_in">ALOGW</span>(<span class="string">&quot;bitmap has unknown configuration so no memory has been allocated&quot;</span>);</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    SkImageRef* pr;</span><br><span class="line">    <span class="comment">// only use ashmem for large images, since mmaps come at a price</span></span><br><span class="line">    <span class="comment">//当Bitmap内存超过32K时，才会使用共享内存</span></span><br><span class="line">    <span class="keyword">if</span> (bitmap-&gt;<span class="built_in">getSize</span>() &gt;= <span class="number">32</span> * <span class="number">1024</span>) &#123;</span><br><span class="line">        pr = <span class="keyword">new</span> <span class="built_in">SkImageRef_ashmem</span>(bitmapInfo, stream, sampleSize);</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="comment">//会走到SkBitmap::allocPixels默认申请内存native内存的分支，并通过一个全局缓存池进行管理</span></span><br><span class="line">        pr = <span class="keyword">new</span> <span class="built_in">SkImageRef_GlobalPool</span>(bitmapInfo, stream, sampleSize);</span><br><span class="line">    &#125;</span><br><span class="line">    pr-&gt;<span class="built_in">setDitherImage</span>(ditherImage);</span><br><span class="line">    bitmap-&gt;<span class="built_in">setPixelRef</span>(pr)-&gt;<span class="built_in">unref</span>();</span><br><span class="line">    pr-&gt;<span class="built_in">isOpaque</span>(bitmap);</span><br><span class="line">    <span class="keyword">return</span> pr;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>从上面代码可以看出，当isPurgeable==true时，并没有解码pixel数据，而且内存也没有申请，那么什么时候进行解码呢？还记得Fresco调用BitmapFactory解码后有个pinBitmap的函数调用吧，这个函数通过jni调用AndroidBitmap_lockPixels函数，进而调用到<code>SkImageRef::onLockPixels</code>，从而触发pixel解码。下面代码介绍了触发解码的过程，以及共享内存的分配：</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//android-4.4.4_r1\external\skia\src\images\SkImageRef.cpp</span></span><br><span class="line"><span class="comment">//Fresco的pinBitmap最终就会调用这个函数，进而触发pixel解码，pixel数据存放在共享内存</span></span><br><span class="line"><span class="function"><span class="type">void</span>* <span class="title">SkImageRef::onLockPixels</span><span class="params">(SkColorTable** ct)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">if</span> (<span class="literal">NULL</span> == fBitmap.<span class="built_in">getPixels</span>()) &#123;</span><br><span class="line">        (<span class="type">void</span>)<span class="keyword">this</span>-&gt;<span class="built_in">prepareBitmap</span>(SkImageDecoder::kDecodePixels_Mode);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (ct) &#123;</span><br><span class="line">        *ct = fBitmap.<span class="built_in">getColorTable</span>();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> fBitmap.<span class="built_in">getPixels</span>();</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//SkImageRef_ashmem就是SkImageRef的子类，prepareBitmap会调用onDecode</span></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">SkImageRef::prepareBitmap</span><span class="params">(SkImageDecoder::Mode mode)</span> </span>&#123;</span><br><span class="line">    ......</span><br><span class="line">    SkImageDecoder* codec;</span><br><span class="line">    <span class="keyword">if</span> (fFactory) &#123; <span class="comment">//默认是null，不走这个分支</span></span><br><span class="line">        codec = fFactory-&gt;<span class="built_in">newDecoder</span>(fStream);</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        codec = SkImageDecoder::<span class="built_in">Factory</span>(fStream);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (codec) &#123;</span><br><span class="line">        <span class="function">SkAutoTDelete&lt;SkImageDecoder&gt; <span class="title">ad</span><span class="params">(codec)</span></span>;</span><br><span class="line"></span><br><span class="line">        codec-&gt;<span class="built_in">setSampleSize</span>(fSampleSize);</span><br><span class="line">        codec-&gt;<span class="built_in">setDitherImage</span>(fDoDither);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//此处就是SkImageRef_ashmem::onDecode，见下面函数定义</span></span><br><span class="line">        <span class="keyword">if</span> (<span class="keyword">this</span>-&gt;<span class="built_in">onDecode</span>(codec, fStream, &amp;fBitmap, fBitmap.<span class="built_in">config</span>(), mode)) &#123;</span><br><span class="line">            <span class="built_in">SkDEBUGCODE</span>(SkImageInfo info;)</span><br><span class="line">            <span class="built_in">SkASSERT</span>(!fBitmap.<span class="built_in">asImageInfo</span>(&amp;info) || <span class="keyword">this</span>-&gt;<span class="built_in">info</span>().fColorType == info.fColorType);</span><br><span class="line">            <span class="built_in">SkASSERT</span>(<span class="keyword">this</span>-&gt;<span class="built_in">info</span>().fWidth == fBitmap.<span class="built_in">width</span>());</span><br><span class="line">            <span class="built_in">SkASSERT</span>(<span class="keyword">this</span>-&gt;<span class="built_in">info</span>().fHeight == fBitmap.<span class="built_in">height</span>());</span><br><span class="line">            <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    ......</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//android-4.4.4_r1\external\skia\src\images\SkImageRef_ashmem.cpp</span></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">SkImageRef_ashmem::onDecode</span><span class="params">(SkImageDecoder* codec, SkStreamRewindable* stream,</span></span></span><br><span class="line"><span class="params"><span class="function">                                 SkBitmap* bitmap, SkBitmap::Config config,</span></span></span><br><span class="line"><span class="params"><span class="function">                                 SkImageDecoder::Mode mode)</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (SkImageDecoder::kDecodeBounds_Mode == mode) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">this</span>-&gt;INHERITED::<span class="built_in">onDecode</span>(codec, stream, bitmap, config, mode);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// Ashmem memory is guaranteed to be initialized to 0.</span></span><br><span class="line">    codec-&gt;<span class="built_in">setSkipWritingZeroes</span>(<span class="literal">true</span>);</span><br><span class="line"></span><br><span class="line">    <span class="comment">//这就是我们的主角，共享内存分配器</span></span><br><span class="line">    <span class="function">AshmemAllocator <span class="title">alloc</span><span class="params">(&amp;fRec, <span class="keyword">this</span>-&gt;getURI())</span></span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//向解码器中注册共享内存分配器。如果不注册将会采用默认的内存分配器</span></span><br><span class="line">    codec-&gt;<span class="built_in">setAllocator</span>(&amp;alloc);</span><br><span class="line"></span><br><span class="line">    <span class="comment">//调用父类的onDecode，父类会调用codec-&gt;decode进行位图解码，见下面函数定义</span></span><br><span class="line">    <span class="type">bool</span> success = <span class="keyword">this</span>-&gt;INHERITED::<span class="built_in">onDecode</span>(codec, stream, bitmap, config,</span><br><span class="line">                                             mode);</span><br><span class="line">    <span class="comment">// remove the allocator, since its on the stack</span></span><br><span class="line">    codec-&gt;<span class="built_in">setAllocator</span>(<span class="literal">NULL</span>);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (success) &#123;</span><br><span class="line">        <span class="comment">// remember the colortable (if any)</span></span><br><span class="line">        <span class="built_in">SkRefCnt_SafeAssign</span>(fCT, bitmap-&gt;<span class="built_in">getColorTable</span>());</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="keyword">if</span> (fRec.fPinned) &#123;</span><br><span class="line">            <span class="built_in">ashmem_unpin_region</span>(fRec.fFD, <span class="number">0</span>, <span class="number">0</span>);</span><br><span class="line">            fRec.fPinned = <span class="literal">false</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">this</span>-&gt;<span class="built_in">closeFD</span>();</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">SkImageRef::onDecode</span><span class="params">(SkImageDecoder* codec, SkStreamRewindable* stream,</span></span></span><br><span class="line"><span class="params"><span class="function">                          SkBitmap* bitmap, SkBitmap::Config config,</span></span></span><br><span class="line"><span class="params"><span class="function">                          SkImageDecoder::Mode mode)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> codec-&gt;<span class="built_in">decode</span>(stream, bitmap, config, mode);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//android-4.4.4_r1\external\skia\src\images\SkImageDecoder_libjpeg.cpp</span></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">SkJPEGImageDecoder::onDecode</span><span class="params">(SkStream* stream, SkBitmap* bm, Mode mode)</span> </span>&#123;</span><br><span class="line">    ......</span><br><span class="line">    <span class="keyword">if</span> (SkImageDecoder::kDecodeBounds_Mode == mode) &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span> (!<span class="keyword">this</span>-&gt;<span class="built_in">allocPixelRef</span>(bm, <span class="literal">NULL</span>)) &#123; <span class="comment">//调用父类函数</span></span><br><span class="line">        <span class="keyword">return</span> <span class="built_in">return_false</span>(cinfo, *bm, <span class="string">&quot;allocPixelRef&quot;</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    ......</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//android-4.4.4_r1\external\skia\src\core\SkBitmap.cpp</span></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">SkImageDecoder::allocPixelRef</span><span class="params">(SkBitmap* bitmap,</span></span></span><br><span class="line"><span class="params"><span class="function">                                   SkColorTable* ctable)</span> <span class="type">const</span> </span>&#123;</span><br><span class="line">    <span class="comment">//调用bitmap分配pixel内存，fAllocator就是前面我们设置的共享内存分配器</span></span><br><span class="line">    <span class="keyword">return</span> bitmap-&gt;<span class="built_in">allocPixels</span>(fAllocator, ctable);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">bool</span> <span class="title">SkBitmap::allocPixels</span><span class="params">(Allocator* allocator, SkColorTable* ctable)</span> </span>&#123;</span><br><span class="line">    <span class="comment">//这是默认内存分配器，因为我们传入了allocator参数，所以不会使用默认内存分配器</span></span><br><span class="line">    <span class="comment">//上面代码中介绍的SkImageRef_GlobalPool就会使用这个默认的内存分配器</span></span><br><span class="line">    HeapAllocator stdalloc;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (<span class="literal">NULL</span> == allocator) &#123;</span><br><span class="line">        allocator = &amp;stdalloc;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//调用AshmemAllocator::allocPixelRef来分配内存</span></span><br><span class="line">    <span class="keyword">return</span> allocator-&gt;<span class="built_in">allocPixelRef</span>(<span class="keyword">this</span>, ctable);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">AshmemAllocator</span> : <span class="keyword">public</span> SkBitmap::Allocator &#123;</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">    <span class="built_in">AshmemAllocator</span>(SkAshmemRec* rec, <span class="type">const</span> <span class="type">char</span> name[])</span><br><span class="line">        : <span class="built_in">fRec</span>(rec), <span class="built_in">fName</span>(name) &#123;&#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">virtual</span> <span class="type">bool</span> <span class="title">allocPixelRef</span><span class="params">(SkBitmap* bm, SkColorTable* ct)</span> </span>&#123;</span><br><span class="line">        <span class="type">const</span> <span class="type">size_t</span> size = <span class="built_in">roundToPageSize</span>(bm-&gt;<span class="built_in">getSize</span>());</span><br><span class="line">        <span class="type">int</span> fd = fRec-&gt;fFD;</span><br><span class="line">        <span class="type">void</span>* addr = fRec-&gt;fAddr;</span><br><span class="line"></span><br><span class="line">        <span class="built_in">SkASSERT</span>(!fRec-&gt;fPinned);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">if</span> (<span class="number">-1</span> == fd) &#123;</span><br><span class="line">            <span class="built_in">SkASSERT</span>(<span class="literal">NULL</span> == addr);</span><br><span class="line">            <span class="built_in">SkASSERT</span>(<span class="number">0</span> == fRec-&gt;fSize);</span><br><span class="line"></span><br><span class="line">            <span class="comment">//打开/dev/ashmem虚拟设备，然后ioctl配置name和size</span></span><br><span class="line">            fd = <span class="built_in">ashmem_create_region</span>(fName, size);</span><br><span class="line">            ......</span><br><span class="line"></span><br><span class="line">            <span class="comment">//调用mmap分配内存</span></span><br><span class="line">            addr = <span class="built_in">mmap</span>(<span class="literal">NULL</span>, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, <span class="number">0</span>);</span><br><span class="line">            ......</span><br><span class="line"></span><br><span class="line">            fRec-&gt;fFD = fd;</span><br><span class="line">            fRec-&gt;fAddr = addr;</span><br><span class="line">            fRec-&gt;fSize = size;</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            <span class="built_in">SkASSERT</span>(addr);</span><br><span class="line">            <span class="built_in">SkASSERT</span>(size == fRec-&gt;fSize);</span><br><span class="line">            (<span class="type">void</span>)<span class="built_in">ashmem_pin_region</span>(fd, <span class="number">0</span>, <span class="number">0</span>);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        bm-&gt;<span class="built_in">setPixels</span>(addr, ct);</span><br><span class="line">        fRec-&gt;fPinned = <span class="literal">true</span>;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">private</span>:</span><br><span class="line">    <span class="comment">// we just point to our caller&#x27;s memory, these are not copies</span></span><br><span class="line">    SkAshmemRec* fRec;</span><br><span class="line">    <span class="type">const</span> <span class="type">char</span>*  fName;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h3 id="Bitmap复用"><a href="#Bitmap复用" class="headerlink" title="Bitmap复用"></a>Bitmap复用</h3><p>通过<code>android.graphics.BitmapFactory#decodeStream(...)</code>接口进行图片解码时可以通过设置<code>BitmapFactory.Options#inBitmap</code>来复用旧的Bitmap实例，这样可以避免频繁申请内存。但是有如下限制条件：</p>
<ol>
<li>被复用的Bitmap的isMutable属性必须为true；</li>
<li>Android4.4及以上版本，只要新图片需要的pixels内存小于等于inBitmap的即可；</li>
<li>Android4.4以下版本有额外的限制，图片必须是jpeg或png格式，而且pixels内存大小必须相等，且inSampleSize必须是1；而且新图片的inPreferredConfig属性将会被inBitmap覆盖。</li>
</ol>
<p>解码时Bitmap的复用代码在<code>DefaultDecoder#decodeFromStream</code>中。被复用的Bitmap保存在BitmapPool中。当一个Bitmap不再被使用后（引用计数为0）就会被放到BitmapPool中：</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="405px" preserveAspectRatio="none" style="width:718px;height:405px;background:#FFFFFF;" version="1.1" viewBox="0 0 718 405" width="718px" zoomAndPan="magnify"><defs/><g><!--class Pool--><g id="elem_Pool"><rect codeLine="1" fill="#F1F1F1" height="48" id="Pool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="109" x="323.5" y="10"/><ellipse cx="338.5" cy="26" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M339.4531,22.7813 L341.1719,22.7813 C341.5625,22.7813 341.75,22.75 341.875,22.6719 C342.1406,22.5156 342.2813,22.2344 342.2813,21.9375 C342.2813,21.6719 342.1719,21.4063 341.9375,21.2344 C341.7656,21.125 341.625,21.0938 341.1719,21.0938 L336.0313,21.0938 C335.5938,21.0938 335.4688,21.1094 335.3125,21.2031 C335.0625,21.3594 334.9063,21.6563 334.9063,21.9375 C334.9063,22.2188 335.0469,22.4688 335.2656,22.6406 C335.4219,22.75 335.6094,22.7813 336.0313,22.7813 L337.75,22.7813 L337.75,29.2969 L336.0313,29.2969 C335.5938,29.2969 335.4688,29.3125 335.3125,29.4219 C335.0625,29.5781 334.9063,29.8594 334.9063,30.1563 C334.9063,30.4063 335.0469,30.6719 335.2656,30.8281 C335.4219,30.9531 335.625,31 336.0313,31 L341.1719,31 C341.9219,31 342.2813,30.7188 342.2813,30.1563 C342.2813,29.875 342.1719,29.625 341.9375,29.4531 C341.7656,29.3281 341.625,29.2969 341.1719,29.2969 L339.4531,29.2969 L339.4531,22.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="30" x="352.5" y="30.8467">Pool</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="45" x="390.5" y="7"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="43" x="391.5" y="19.1387">Bitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="324.5" x2="431.5" y1="42" y2="42"/><line style="stroke:#181818;stroke-width:0.5;" x1="324.5" x2="431.5" y1="50" y2="50"/></g><!--class BitmapPool--><g id="elem_BitmapPool"><rect codeLine="2" fill="#ADD8E6" height="48" id="BitmapPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="113" x="229.5" y="118"/><ellipse cx="244.5" cy="134" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M245.4531,130.7813 L247.1719,130.7813 C247.5625,130.7813 247.75,130.75 247.875,130.6719 C248.1406,130.5156 248.2813,130.2344 248.2813,129.9375 C248.2813,129.6719 248.1719,129.4063 247.9375,129.2344 C247.7656,129.125 247.625,129.0938 247.1719,129.0938 L242.0313,129.0938 C241.5938,129.0938 241.4688,129.1094 241.3125,129.2031 C241.0625,129.3594 240.9063,129.6563 240.9063,129.9375 C240.9063,130.2188 241.0469,130.4688 241.2656,130.6406 C241.4219,130.75 241.6094,130.7813 242.0313,130.7813 L243.75,130.7813 L243.75,137.2969 L242.0313,137.2969 C241.5938,137.2969 241.4688,137.3125 241.3125,137.4219 C241.0625,137.5781 240.9063,137.8594 240.9063,138.1563 C240.9063,138.4063 241.0469,138.6719 241.2656,138.8281 C241.4219,138.9531 241.625,139 242.0313,139 L247.1719,139 C247.9219,139 248.2813,138.7188 248.2813,138.1563 C248.2813,137.875 248.1719,137.625 247.9375,137.4531 C247.7656,137.3281 247.625,137.2969 247.1719,137.2969 L245.4531,137.2969 L245.4531,130.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="81" x="258.5" y="138.8467">BitmapPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="230.5" x2="341.5" y1="150" y2="150"/><line style="stroke:#181818;stroke-width:0.5;" x1="230.5" x2="341.5" y1="158" y2="158"/></g><!--class BasePool--><g id="elem_BasePool"><rect codeLine="4" fill="#F1F1F1" height="48" id="BasePool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="144" x="398" y="118"/><ellipse cx="413" cy="134" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M415.0781,135.8125 L415.4688,136.7969 L415.0781,136.7969 C414.625,136.7969 414.5156,136.8125 414.3594,136.9219 C414.1094,137.0781 413.9531,137.3594 413.9531,137.6563 C413.9531,137.9219 414.0938,138.1719 414.3125,138.3281 C414.4531,138.4531 414.6563,138.5 415.0781,138.5 L417.4375,138.5 C417.7969,138.5 418.0156,138.4688 418.1563,138.375 C418.4063,138.2344 418.5625,137.9375 418.5625,137.6563 C418.5625,137.375 418.4219,137.125 418.2031,136.9688 C418.0313,136.8281 417.875,136.7969 417.4063,136.7969 L414.0156,128.5938 L410.3438,128.5938 C409.8906,128.5938 409.7656,128.6094 409.6094,128.7031 C409.3594,128.875 409.2031,129.1563 409.2031,129.4375 C409.2031,129.7188 409.3438,129.9688 409.5625,130.1406 C409.7344,130.25 409.9063,130.2813 410.3438,130.2813 L411.4219,130.2813 L408.7813,136.7969 C408.3594,136.7969 408.2031,136.8125 408.0469,136.9219 C407.7969,137.0781 407.6406,137.3594 407.6406,137.6563 C407.6406,138.2188 408.0156,138.5 408.7656,138.5 L411.0313,138.5 C411.3906,138.5 411.6094,138.4688 411.7344,138.375 C412,138.2344 412.1406,137.9375 412.1406,137.6563 C412.1406,137.375 412.0156,137.125 411.7969,136.9531 C411.625,136.8281 411.4844,136.7969 411.0313,136.7969 L410.6406,136.7969 L411.0313,135.8125 L415.0781,135.8125 Z M414.375,134.1094 L411.7031,134.1094 L413.0469,130.8438 L414.375,134.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="65" x="427" y="138.8467">BasePool</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="45" x="500" y="115"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="43" x="501" y="127.1387">Bitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="399" x2="541" y1="150" y2="150"/><line style="stroke:#181818;stroke-width:0.5;" x1="399" x2="541" y1="158" y2="158"/></g><!--class BucketsBitmapPool--><g id="elem_BucketsBitmapPool"><rect fill="#F1F1F1" height="48" id="BucketsBitmapPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="174" x="387" y="226"/><ellipse cx="402" cy="242" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M404.3438,237.6719 C403.4063,237.2344 402.8125,237.0938 401.9375,237.0938 C399.3125,237.0938 397.3125,239.1719 397.3125,241.8906 L397.3125,243.0156 C397.3125,245.5938 399.4219,247.4844 402.3125,247.4844 C403.5313,247.4844 404.6875,247.1875 405.4375,246.6406 C406.0156,246.2344 406.3438,245.7813 406.3438,245.3906 C406.3438,244.9375 405.9531,244.5469 405.4844,244.5469 C405.2656,244.5469 405.0625,244.625 404.875,244.8125 C404.4219,245.2969 404.4219,245.2969 404.2344,245.3906 C403.8125,245.6563 403.125,245.7813 402.3594,245.7813 C400.3125,245.7813 399.0156,244.6875 399.0156,242.9844 L399.0156,241.8906 C399.0156,240.1094 400.2656,238.7969 402,238.7969 C402.5781,238.7969 403.1875,238.9531 403.6563,239.2031 C404.1406,239.4844 404.3125,239.7031 404.4063,240.1094 C404.4688,240.5156 404.5,240.6406 404.6406,240.7656 C404.7813,240.9063 405.0156,241.0156 405.2344,241.0156 C405.5,241.0156 405.7656,240.875 405.9375,240.6563 C406.0469,240.5 406.0781,240.3125 406.0781,239.8906 L406.0781,238.4688 C406.0781,238.0313 406.0625,237.9063 405.9688,237.75 C405.8125,237.4844 405.5313,237.3438 405.2344,237.3438 C404.9375,237.3438 404.7344,237.4375 404.5156,237.75 L404.3438,237.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="142" x="416" y="246.8467">BucketsBitmapPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="388" x2="560" y1="258" y2="258"/><line style="stroke:#181818;stroke-width:0.5;" x1="388" x2="560" y1="266" y2="266"/></g><!--class DummyBitmapPool--><g id="elem_DummyBitmapPool"><rect fill="#F1F1F1" height="48" id="DummyBitmapPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="171" x="180.5" y="226"/><ellipse cx="195.5" cy="242" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M197.8438,237.6719 C196.9063,237.2344 196.3125,237.0938 195.4375,237.0938 C192.8125,237.0938 190.8125,239.1719 190.8125,241.8906 L190.8125,243.0156 C190.8125,245.5938 192.9219,247.4844 195.8125,247.4844 C197.0313,247.4844 198.1875,247.1875 198.9375,246.6406 C199.5156,246.2344 199.8438,245.7813 199.8438,245.3906 C199.8438,244.9375 199.4531,244.5469 198.9844,244.5469 C198.7656,244.5469 198.5625,244.625 198.375,244.8125 C197.9219,245.2969 197.9219,245.2969 197.7344,245.3906 C197.3125,245.6563 196.625,245.7813 195.8594,245.7813 C193.8125,245.7813 192.5156,244.6875 192.5156,242.9844 L192.5156,241.8906 C192.5156,240.1094 193.7656,238.7969 195.5,238.7969 C196.0781,238.7969 196.6875,238.9531 197.1563,239.2031 C197.6406,239.4844 197.8125,239.7031 197.9063,240.1094 C197.9688,240.5156 198,240.6406 198.1406,240.7656 C198.2813,240.9063 198.5156,241.0156 198.7344,241.0156 C199,241.0156 199.2656,240.875 199.4375,240.6563 C199.5469,240.5 199.5781,240.3125 199.5781,239.8906 L199.5781,238.4688 C199.5781,238.0313 199.5625,237.9063 199.4688,237.75 C199.3125,237.4844 199.0313,237.3438 198.7344,237.3438 C198.4375,237.3438 198.2344,237.4375 198.0156,237.75 L197.8438,237.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="139" x="209.5" y="246.8467">DummyBitmapPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="181.5" x2="350.5" y1="258" y2="258"/><line style="stroke:#181818;stroke-width:0.5;" x1="181.5" x2="350.5" y1="266" y2="266"/></g><!--class LruBitmapPool--><g id="elem_LruBitmapPool"><rect fill="#F1F1F1" height="48" id="LruBitmapPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="138" x="7" y="226"/><ellipse cx="22" cy="242" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M24.3438,237.6719 C23.4063,237.2344 22.8125,237.0938 21.9375,237.0938 C19.3125,237.0938 17.3125,239.1719 17.3125,241.8906 L17.3125,243.0156 C17.3125,245.5938 19.4219,247.4844 22.3125,247.4844 C23.5313,247.4844 24.6875,247.1875 25.4375,246.6406 C26.0156,246.2344 26.3438,245.7813 26.3438,245.3906 C26.3438,244.9375 25.9531,244.5469 25.4844,244.5469 C25.2656,244.5469 25.0625,244.625 24.875,244.8125 C24.4219,245.2969 24.4219,245.2969 24.2344,245.3906 C23.8125,245.6563 23.125,245.7813 22.3594,245.7813 C20.3125,245.7813 19.0156,244.6875 19.0156,242.9844 L19.0156,241.8906 C19.0156,240.1094 20.2656,238.7969 22,238.7969 C22.5781,238.7969 23.1875,238.9531 23.6563,239.2031 C24.1406,239.4844 24.3125,239.7031 24.4063,240.1094 C24.4688,240.5156 24.5,240.6406 24.6406,240.7656 C24.7813,240.9063 25.0156,241.0156 25.2344,241.0156 C25.5,241.0156 25.7656,240.875 25.9375,240.6563 C26.0469,240.5 26.0781,240.3125 26.0781,239.8906 L26.0781,238.4688 C26.0781,238.0313 26.0625,237.9063 25.9688,237.75 C25.8125,237.4844 25.5313,237.3438 25.2344,237.3438 C24.9375,237.3438 24.7344,237.4375 24.5156,237.75 L24.3438,237.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="106" x="36" y="246.8467">LruBitmapPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="144" y1="258" y2="258"/><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="144" y1="266" y2="266"/></g><!--class PoolFactory--><g id="elem_PoolFactory"><rect codeLine="10" fill="#F1F1F1" height="64.2969" id="PoolFactory" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="219" x="156.5" y="334"/><ellipse cx="219.25" cy="350" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M221.5938,345.6719 C220.6563,345.2344 220.0625,345.0938 219.1875,345.0938 C216.5625,345.0938 214.5625,347.1719 214.5625,349.8906 L214.5625,351.0156 C214.5625,353.5938 216.6719,355.4844 219.5625,355.4844 C220.7813,355.4844 221.9375,355.1875 222.6875,354.6406 C223.2656,354.2344 223.5938,353.7813 223.5938,353.3906 C223.5938,352.9375 223.2031,352.5469 222.7344,352.5469 C222.5156,352.5469 222.3125,352.625 222.125,352.8125 C221.6719,353.2969 221.6719,353.2969 221.4844,353.3906 C221.0625,353.6563 220.375,353.7813 219.6094,353.7813 C217.5625,353.7813 216.2656,352.6875 216.2656,350.9844 L216.2656,349.8906 C216.2656,348.1094 217.5156,346.7969 219.25,346.7969 C219.8281,346.7969 220.4375,346.9531 220.9063,347.2031 C221.3906,347.4844 221.5625,347.7031 221.6563,348.1094 C221.7188,348.5156 221.75,348.6406 221.8906,348.7656 C222.0313,348.9063 222.2656,349.0156 222.4844,349.0156 C222.75,349.0156 223.0156,348.875 223.1875,348.6563 C223.2969,348.5 223.3281,348.3125 223.3281,347.8906 L223.3281,346.4688 C223.3281,346.0313 223.3125,345.9063 223.2188,345.75 C223.0625,345.4844 222.7813,345.3438 222.4844,345.3438 C222.1875,345.3438 221.9844,345.4375 221.7656,345.75 L221.5938,345.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="85" x="239.75" y="354.8467">PoolFactory</text><line style="stroke:#181818;stroke-width:0.5;" x1="157.5" x2="374.5" y1="366" y2="366"/><line style="stroke:#181818;stroke-width:0.5;" x1="157.5" x2="374.5" y1="374" y2="374"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="207" x="162.5" y="390.9951">BitmapPool getBitmapPool()</text></g><!--class Bucket--><g id="elem_Bucket"><rect codeLine="16" fill="#F1F1F1" height="48" id="Bucket" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="130" x="577" y="118"/><ellipse cx="592" cy="134" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M594.3438,129.6719 C593.4063,129.2344 592.8125,129.0938 591.9375,129.0938 C589.3125,129.0938 587.3125,131.1719 587.3125,133.8906 L587.3125,135.0156 C587.3125,137.5938 589.4219,139.4844 592.3125,139.4844 C593.5313,139.4844 594.6875,139.1875 595.4375,138.6406 C596.0156,138.2344 596.3438,137.7813 596.3438,137.3906 C596.3438,136.9375 595.9531,136.5469 595.4844,136.5469 C595.2656,136.5469 595.0625,136.625 594.875,136.8125 C594.4219,137.2969 594.4219,137.2969 594.2344,137.3906 C593.8125,137.6563 593.125,137.7813 592.3594,137.7813 C590.3125,137.7813 589.0156,136.6875 589.0156,134.9844 L589.0156,133.8906 C589.0156,132.1094 590.2656,130.7969 592,130.7969 C592.5781,130.7969 593.1875,130.9531 593.6563,131.2031 C594.1406,131.4844 594.3125,131.7031 594.4063,132.1094 C594.4688,132.5156 594.5,132.6406 594.6406,132.7656 C594.7813,132.9063 595.0156,133.0156 595.2344,133.0156 C595.5,133.0156 595.7656,132.875 595.9375,132.6563 C596.0469,132.5 596.0781,132.3125 596.0781,131.8906 L596.0781,130.4688 C596.0781,130.0313 596.0625,129.9063 595.9688,129.75 C595.8125,129.4844 595.5313,129.3438 595.2344,129.3438 C594.9375,129.3438 594.7344,129.4375 594.5156,129.75 L594.3438,129.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="51" x="606" y="138.8467">Bucket</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="45" x="665" y="115"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="43" x="666" y="127.1387">Bitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="578" x2="706" y1="150" y2="150"/><line style="stroke:#181818;stroke-width:0.5;" x1="578" x2="706" y1="158" y2="158"/></g><!--class Bitmap--><g id="elem_Bitmap"><rect fill="#F1F1F1" height="48" id="Bitmap" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="85" x="599.5" y="226"/><ellipse cx="614.5" cy="242" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M616.8438,237.6719 C615.9063,237.2344 615.3125,237.0938 614.4375,237.0938 C611.8125,237.0938 609.8125,239.1719 609.8125,241.8906 L609.8125,243.0156 C609.8125,245.5938 611.9219,247.4844 614.8125,247.4844 C616.0313,247.4844 617.1875,247.1875 617.9375,246.6406 C618.5156,246.2344 618.8438,245.7813 618.8438,245.3906 C618.8438,244.9375 618.4531,244.5469 617.9844,244.5469 C617.7656,244.5469 617.5625,244.625 617.375,244.8125 C616.9219,245.2969 616.9219,245.2969 616.7344,245.3906 C616.3125,245.6563 615.625,245.7813 614.8594,245.7813 C612.8125,245.7813 611.5156,244.6875 611.5156,242.9844 L611.5156,241.8906 C611.5156,240.1094 612.7656,238.7969 614.5,238.7969 C615.0781,238.7969 615.6875,238.9531 616.1563,239.2031 C616.6406,239.4844 616.8125,239.7031 616.9063,240.1094 C616.9688,240.5156 617,240.6406 617.1406,240.7656 C617.2813,240.9063 617.5156,241.0156 617.7344,241.0156 C618,241.0156 618.2656,240.875 618.4375,240.6563 C618.5469,240.5 618.5781,240.3125 618.5781,239.8906 L618.5781,238.4688 C618.5781,238.0313 618.5625,237.9063 618.4688,237.75 C618.3125,237.4844 618.0313,237.3438 617.7344,237.3438 C617.4375,237.3438 617.2344,237.4375 617.0156,237.75 L616.8438,237.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="53" x="628.5" y="246.8467">Bitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="600.5" x2="683.5" y1="258" y2="258"/><line style="stroke:#181818;stroke-width:0.5;" x1="600.5" x2="683.5" y1="266" y2="266"/></g><!--reverse link Pool to BitmapPool--><g id="link_Pool_BitmapPool"><path codeLine="3" d="M346.2388,71.5942 C330.9138,89.2522 321.636,99.941 306.241,117.678 " fill="none" id="Pool-backto-BitmapPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="358.037,58,341.7074,67.6615,350.7703,75.527,358.037,58" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link Pool to BasePool--><g id="link_Pool_BasePool"><path codeLine="5" d="M409.7612,71.5942 C425.0862,89.2522 434.364,99.941 449.759,117.678 " fill="none" id="Pool-backto-BasePool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="397.963,58,405.2297,75.527,414.2926,67.6615,397.963,58" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BasePool to BucketsBitmapPool--><g id="link_BasePool_BucketsBitmapPool"><path codeLine="6" d="M471.5464,183.9872 C472.2124,201.6452 472.451,207.941 473.12,225.678 " fill="none" id="BasePool-backto-BucketsBitmapPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="470.868,166,465.5507,184.2133,477.5422,183.7611,470.868,166" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BitmapPool to BucketsBitmapPool--><g id="link_BitmapPool_BucketsBitmapPool"><path codeLine="7" d="M342.4724,174.8406 C373.8984,192.5596 401.475,208.108 432.962,225.862 " fill="none" id="BitmapPool-backto-BucketsBitmapPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="326.793,166,339.5256,180.067,345.4193,169.6141,326.793,166" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BitmapPool to DummyBitmapPool--><g id="link_BitmapPool_DummyBitmapPool"><path codeLine="8" d="M278.3233,183.688 C274.9923,201.346 273.747,207.941 270.4,225.678 " fill="none" id="BitmapPool-backto-DummyBitmapPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="281.66,166,272.4273,182.5758,284.2193,184.8003,281.66,166" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BitmapPool to LruBitmapPool--><g id="link_BitmapPool_LruBitmapPool"><path codeLine="9" d="M224.3641,174.1111 C189.2611,191.8301 157.012,208.108 121.84,225.862 " fill="none" id="BitmapPool-backto-LruBitmapPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="240.433,166,221.6604,168.7548,227.0678,179.4674,240.433,166" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BucketsBitmapPool to PoolFactory--><g id="link_BucketsBitmapPool_PoolFactory"><path codeLine="13" d="M426.6464,276.9538 C395.1894,294.1948 357.112,315.0637 322.618,333.969 " fill="none" id="BucketsBitmapPool-backto-PoolFactory" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="431.908,274.07,422.0932,274.8879,427.5234,276.4731,425.9382,281.9033,431.908,274.07" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DummyBitmapPool to PoolFactory--><g id="link_DummyBitmapPool_PoolFactory"><path codeLine="14" d="M266,280.07 C266,297.246 266,314.8845 266,333.7548 " fill="none" id="DummyBitmapPool-backto-PoolFactory" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="266,274.07,262,283.07,266,279.07,270,283.07,266,274.07" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link LruBitmapPool to PoolFactory--><g id="link_LruBitmapPool_PoolFactory"><path codeLine="15" d="M119.594,277.1569 C148.33,294.3979 182.773,315.0637 214.282,333.969 " fill="none" id="LruBitmapPool-backto-PoolFactory" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="114.449,274.07,120.1086,282.1303,118.7365,276.6424,124.2244,275.2703,114.449,274.07" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BasePool to Bucket--><g id="link_BasePool_Bucket"><path codeLine="17" d="M554.227,142 C565.789,142 565.351,142 576.913,142 " fill="none" id="BasePool-backto-Bucket" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="542.227,142,548.227,146,554.227,142,548.227,138,542.227,142" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="8" x="550.0879" y="138.3003">1</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="8" x="560.9248" y="138.2074">n</text></g><!--reverse link Bucket to Bitmap--><g id="link_Bucket_Bitmap"><path codeLine="18" d="M642,178 C642,195.658 642,207.941 642,225.678 " fill="none" id="Bucket-backto-Bitmap" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="642,166,638,172,642,178,646,172,642,166" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="8" x="632.975" y="186.1558">1</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="8" x="633.025" y="215.0045">n</text></g><!--SRC=[ZL2x3i8m3Dpp5LPO02a3UzMXGamC_48QfIKYVQXnXWhuTr9IYg4L8fDzTpvVR6hKNI6LXbFJs2GpMCasPMQ28pAGiBAcF6DklMRFFha9GNWcSuUTL0ZAIkSWaqv_c9AXaMAlOeIzkcXqn99i_rEnzrNL_-2FdITiJ3gKXn2ywNguCWYFJ9KQtzrwm-wCoeLlHReGQwxv3ZPNB4MBpjC9OmkyvY2iBb1iWUyukUV81smRFZleukW3]--></g></svg>

<p>BitmapPool默认情况下使用BucketsBitmapPool和DummyBitmapPool，Android5.0及以上使用BucketsBitmapPool。</p>
<p>Bitmap是如何被放到BitmapPool中的呢？<code>DefaultDecoder.decodeFromStream</code>生成Bitmap后并不是直接返回一个Bitmap，而是一个CloseableReference，CloseableReference就会把Bitmap与BitmapPool进行关联，代码如下：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//DefaultDecoder.java</span></span><br><span class="line">  <span class="keyword">private</span> CloseableReference&lt;Bitmap&gt; <span class="title function_">decodeFromStream</span><span class="params">(</span></span><br><span class="line"><span class="params">      InputStream inputStream,</span></span><br><span class="line"><span class="params">      BitmapFactory.Options options,</span></span><br><span class="line"><span class="params">      <span class="meta">@Nullable</span> Rect regionToDecode,</span></span><br><span class="line"><span class="params">      <span class="meta">@Nullable</span> <span class="keyword">final</span> ColorSpace colorSpace)</span> &#123;</span><br><span class="line">    ...... <span class="comment">//代码省略</span></span><br><span class="line">    <span class="keyword">return</span> CloseableReference.of(decodedBitmap, mBitmapPool);</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<p>每次<code>CloseableReference#close</code>都会导致Bitmap的引用计数减一，当计数为零后，就会调用到<code>BitmapPool#release</code>，把Bitmap放到BitmapPool中。release的含义就是把不再使用的Bitmap放到缓存池中备用。</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="504px" preserveAspectRatio="none" style="width:583px;height:504px;background:#FFFFFF;" version="1.1" viewBox="0 0 583 504" width="583px" zoomAndPan="magnify"><defs/><g><!--class CloseableReference--><g id="elem_CloseableReference"><rect codeLine="1" fill="#F1F1F1" height="64.2969" id="CloseableReference" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="223" x="155" y="10"/><ellipse cx="170" cy="26" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M172.0781,27.8125 L172.4688,28.7969 L172.0781,28.7969 C171.625,28.7969 171.5156,28.8125 171.3594,28.9219 C171.1094,29.0781 170.9531,29.3594 170.9531,29.6563 C170.9531,29.9219 171.0938,30.1719 171.3125,30.3281 C171.4531,30.4531 171.6563,30.5 172.0781,30.5 L174.4375,30.5 C174.7969,30.5 175.0156,30.4688 175.1563,30.375 C175.4063,30.2344 175.5625,29.9375 175.5625,29.6563 C175.5625,29.375 175.4219,29.125 175.2031,28.9688 C175.0313,28.8281 174.875,28.7969 174.4063,28.7969 L171.0156,20.5938 L167.3438,20.5938 C166.8906,20.5938 166.7656,20.6094 166.6094,20.7031 C166.3594,20.875 166.2031,21.1563 166.2031,21.4375 C166.2031,21.7188 166.3438,21.9688 166.5625,22.1406 C166.7344,22.25 166.9063,22.2813 167.3438,22.2813 L168.4219,22.2813 L165.7813,28.7969 C165.3594,28.7969 165.2031,28.8125 165.0469,28.9219 C164.7969,29.0781 164.6406,29.3594 164.6406,29.6563 C164.6406,30.2188 165.0156,30.5 165.7656,30.5 L168.0313,30.5 C168.3906,30.5 168.6094,30.4688 168.7344,30.375 C169,30.2344 169.1406,29.9375 169.1406,29.6563 C169.1406,29.375 169.0156,29.125 168.7969,28.9531 C168.625,28.8281 168.4844,28.7969 168.0313,28.7969 L167.6406,28.7969 L168.0313,27.8125 L172.0781,27.8125 Z M171.375,26.1094 L168.7031,26.1094 L170.0469,22.8438 L171.375,26.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="144" x="184" y="30.8467">CloseableReference</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="45" x="336" y="7"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="43" x="337" y="19.1387">Bitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="156" x2="377" y1="42" y2="42"/><line style="stroke:#181818;stroke-width:0.5;" x1="156" x2="377" y1="50" y2="50"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="81" x="161" y="66.9951">void close()</text></g><!--class SharedReference--><g id="elem_SharedReference"><rect codeLine="4" fill="#F1F1F1" height="80.5938" id="SharedReference" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="204" x="165.5" y="159"/><ellipse cx="180.5" cy="175" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M182.8438,170.6719 C181.9063,170.2344 181.3125,170.0938 180.4375,170.0938 C177.8125,170.0938 175.8125,172.1719 175.8125,174.8906 L175.8125,176.0156 C175.8125,178.5938 177.9219,180.4844 180.8125,180.4844 C182.0313,180.4844 183.1875,180.1875 183.9375,179.6406 C184.5156,179.2344 184.8438,178.7813 184.8438,178.3906 C184.8438,177.9375 184.4531,177.5469 183.9844,177.5469 C183.7656,177.5469 183.5625,177.625 183.375,177.8125 C182.9219,178.2969 182.9219,178.2969 182.7344,178.3906 C182.3125,178.6563 181.625,178.7813 180.8594,178.7813 C178.8125,178.7813 177.5156,177.6875 177.5156,175.9844 L177.5156,174.8906 C177.5156,173.1094 178.7656,171.7969 180.5,171.7969 C181.0781,171.7969 181.6875,171.9531 182.1563,172.2031 C182.6406,172.4844 182.8125,172.7031 182.9063,173.1094 C182.9688,173.5156 183,173.6406 183.1406,173.7656 C183.2813,173.9063 183.5156,174.0156 183.7344,174.0156 C184,174.0156 184.2656,173.875 184.4375,173.6563 C184.5469,173.5 184.5781,173.3125 184.5781,172.8906 L184.5781,171.4688 C184.5781,171.0313 184.5625,170.9063 184.4688,170.75 C184.3125,170.4844 184.0313,170.3438 183.7344,170.3438 C183.4375,170.3438 183.2344,170.4375 183.0156,170.75 L182.8438,170.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="125" x="194.5" y="179.8467">SharedReference</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="45" x="327.5" y="156"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="43" x="328.5" y="168.1387">Bitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="166.5" x2="368.5" y1="191" y2="191"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="176" x="171.5" y="207.9951">int mRefCount //&#24341;&#29992;&#35745;&#25968;</text><line style="stroke:#181818;stroke-width:0.5;" x1="166.5" x2="368.5" y1="215.2969" y2="215.2969"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="132" x="171.5" y="232.292">deleteReference()</text></g><!--class ResourceReleaser--><g id="elem_ResourceReleaser"><rect codeLine="10" fill="#F1F1F1" height="64.2969" id="ResourceReleaser" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="209" x="163" y="304"/><ellipse cx="178" cy="320" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M178.9531,316.7813 L180.6719,316.7813 C181.0625,316.7813 181.25,316.75 181.375,316.6719 C181.6406,316.5156 181.7813,316.2344 181.7813,315.9375 C181.7813,315.6719 181.6719,315.4063 181.4375,315.2344 C181.2656,315.125 181.125,315.0938 180.6719,315.0938 L175.5313,315.0938 C175.0938,315.0938 174.9688,315.1094 174.8125,315.2031 C174.5625,315.3594 174.4063,315.6563 174.4063,315.9375 C174.4063,316.2188 174.5469,316.4688 174.7656,316.6406 C174.9219,316.75 175.1094,316.7813 175.5313,316.7813 L177.25,316.7813 L177.25,323.2969 L175.5313,323.2969 C175.0938,323.2969 174.9688,323.3125 174.8125,323.4219 C174.5625,323.5781 174.4063,323.8594 174.4063,324.1563 C174.4063,324.4063 174.5469,324.6719 174.7656,324.8281 C174.9219,324.9531 175.125,325 175.5313,325 L180.6719,325 C181.4219,325 181.7813,324.7188 181.7813,324.1563 C181.7813,323.875 181.6719,323.625 181.4375,323.4531 C181.2656,323.3281 181.125,323.2969 180.6719,323.2969 L178.9531,323.2969 L178.9531,316.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="130" x="192" y="324.8467">ResourceReleaser</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="45" x="330" y="301"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="43" x="331" y="313.1387">Bitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="164" x2="371" y1="336" y2="336"/><line style="stroke:#181818;stroke-width:0.5;" x1="164" x2="371" y1="344" y2="344"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="161" x="169" y="360.9951">void release(Bitmap v)</text></g><!--class BitmapPool--><g id="elem_BitmapPool"><rect codeLine="13" fill="#F1F1F1" height="64.2969" id="BitmapPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="173" x="181" y="433"/><ellipse cx="223" cy="449" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M223.9531,445.7813 L225.6719,445.7813 C226.0625,445.7813 226.25,445.75 226.375,445.6719 C226.6406,445.5156 226.7813,445.2344 226.7813,444.9375 C226.7813,444.6719 226.6719,444.4063 226.4375,444.2344 C226.2656,444.125 226.125,444.0938 225.6719,444.0938 L220.5313,444.0938 C220.0938,444.0938 219.9688,444.1094 219.8125,444.2031 C219.5625,444.3594 219.4063,444.6563 219.4063,444.9375 C219.4063,445.2188 219.5469,445.4688 219.7656,445.6406 C219.9219,445.75 220.1094,445.7813 220.5313,445.7813 L222.25,445.7813 L222.25,452.2969 L220.5313,452.2969 C220.0938,452.2969 219.9688,452.3125 219.8125,452.4219 C219.5625,452.5781 219.4063,452.8594 219.4063,453.1563 C219.4063,453.4063 219.5469,453.6719 219.7656,453.8281 C219.9219,453.9531 220.125,454 220.5313,454 L225.6719,454 C226.4219,454 226.7813,453.7188 226.7813,453.1563 C226.7813,452.875 226.6719,452.625 226.4375,452.4531 C226.2656,452.3281 226.125,452.2969 225.6719,452.2969 L223.9531,452.2969 L223.9531,445.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="81" x="243" y="453.8467">BitmapPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="182" x2="353" y1="465" y2="465"/><line style="stroke:#181818;stroke-width:0.5;" x1="182" x2="353" y1="473" y2="473"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="161" x="187" y="489.9951">void release(Bitmap v)</text></g><!--class Bitmap--><g id="elem_Bitmap"><rect fill="#F1F1F1" height="48" id="Bitmap" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="85" x="7" y="175"/><ellipse cx="22" cy="191" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M24.3438,186.6719 C23.4063,186.2344 22.8125,186.0938 21.9375,186.0938 C19.3125,186.0938 17.3125,188.1719 17.3125,190.8906 L17.3125,192.0156 C17.3125,194.5938 19.4219,196.4844 22.3125,196.4844 C23.5313,196.4844 24.6875,196.1875 25.4375,195.6406 C26.0156,195.2344 26.3438,194.7813 26.3438,194.3906 C26.3438,193.9375 25.9531,193.5469 25.4844,193.5469 C25.2656,193.5469 25.0625,193.625 24.875,193.8125 C24.4219,194.2969 24.4219,194.2969 24.2344,194.3906 C23.8125,194.6563 23.125,194.7813 22.3594,194.7813 C20.3125,194.7813 19.0156,193.6875 19.0156,191.9844 L19.0156,190.8906 C19.0156,189.1094 20.2656,187.7969 22,187.7969 C22.5781,187.7969 23.1875,187.9531 23.6563,188.2031 C24.1406,188.4844 24.3125,188.7031 24.4063,189.1094 C24.4688,189.5156 24.5,189.6406 24.6406,189.7656 C24.7813,189.9063 25.0156,190.0156 25.2344,190.0156 C25.5,190.0156 25.7656,189.875 25.9375,189.6563 C26.0469,189.5 26.0781,189.3125 26.0781,188.8906 L26.0781,187.4688 C26.0781,187.0313 26.0625,186.9063 25.9688,186.75 C25.8125,186.4844 25.5313,186.3438 25.2344,186.3438 C24.9375,186.3438 24.7344,186.4375 24.5156,186.75 L24.3438,186.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="53" x="36" y="195.8467">Bitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="91" y1="207" y2="207"/><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="91" y1="215" y2="215"/></g><!--reverse link CloseableReference to SharedReference--><g id="link_CloseableReference_SharedReference"><path codeLine="8" d="M261.5641,89.9909 C260.6671,99.6829 260.948,98.264 260.5,108 C259.801,123.186 260.636,139.785 261.944,154.546 " fill="none" id="CloseableReference-backto-SharedReference" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="262.67,78.042,258.1341,83.6478,261.5641,89.9909,266.1,84.3851,262.67,78.042" style="stroke:#181818;stroke-width:1.0;"/></g><!--link CloseableReference to SharedReference--><g id="link_CloseableReference_SharedReference"><path codeLine="9" d="M379.5,62 C452.942,62 449.942,227 376.5,227 " fill="none" id="CloseableReference-to-SharedReference" style="stroke:#008000;stroke-width:1.0;stroke-dasharray:7.0,7.0;"/><polygon fill="#008000" points="370.5,227,379.5,231,375.5,227,379.5,223,370.5,227" style="stroke:#008000;stroke-width:1.0;"/><text fill="#008000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="26" x="430.5" y="121.0669">&#35843;&#29992;</text></g><!--reverse link ResourceReleaser to BitmapPool--><g id="link_ResourceReleaser_BitmapPool"><path codeLine="16" d="M267.5,386.068 C267.5,404.426 267.5,409.7285 267.5,428.7697 " fill="none" id="ResourceReleaser-backto-BitmapPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="267.5,368.068,261.5,386.068,273.5,386.068,267.5,368.068" style="stroke:#181818;stroke-width:1.0;"/></g><!--link Bitmap to SharedReference--><g id="link_Bitmap_SharedReference"><path codeLine="17" d="M92.0781,199 C113.777,199 123.477,199 145.176,199 " fill="none" id="Bitmap-to-SharedReference" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="157.176,199,151.176,195,145.176,199,151.176,203,157.176,199" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link SharedReference to ResourceReleaser--><g id="link_SharedReference_ResourceReleaser"><path codeLine="18" d="M267.5,255.086 C267.5,274.84 267.5,285.819 267.5,303.859 " fill="none" id="SharedReference-backto-ResourceReleaser" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="267.5,243.086,263.5,249.086,267.5,255.086,271.5,249.086,267.5,243.086" style="stroke:#181818;stroke-width:1.0;"/></g><!--link SharedReference to BitmapPool--><g id="link_SharedReference_BitmapPool"><path codeLine="19" d="M370.5,227 C485.36,227 476.36,485 361.5,485 " fill="none" id="SharedReference-to-BitmapPool" style="stroke:#0000FF;stroke-width:1.0;stroke-dasharray:1.0,3.0;"/><polygon fill="#0000FF" points="355.5,485,364.5,489,360.5,485,364.5,481,355.5,485" style="stroke:#0000FF;stroke-width:1.0;"/><text fill="#0000FF" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="125" x="450.5" y="340.5669">&#24403;&#24341;&#29992;&#35745;&#25968;&#20026;0&#26102;&#35843;&#29992;</text></g><!--link Bitmap to BitmapPool--><g id="link_Bitmap_BitmapPool"><path codeLine="20" d="M41.2317,223.047 C30.6095,256.691 16.0516,320.417 38.5,368 C73.3909,441.957 92.7258,485 174.5,485 " fill="none" id="Bitmap-to-BitmapPool" style="stroke:#FF0000;stroke-width:1.0;stroke-dasharray:7.0,7.0;"/><polygon fill="#FF0000" points="180.5,485,171.5,481,175.5,485,171.5,489,180.5,485" style="stroke:#FF0000;stroke-width:1.0;"/><text fill="#FF0000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="105" x="39.5" y="333.0669">release&#25226;Bitmap</text><text fill="#FF0000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="91" x="46.5" y="348.1997">&#37322;&#25918;&#21040;&#32531;&#23384;&#27744;&#20013;</text></g><!--SRC=[XL7DJi904BxtAIRXWYO5pmlX82zWyEfbQGTfidJDxa9Cr9C7JQz0zAWtBnYy66BGfw45tyBf3wbf8VJKp7n_yotlQgEuOy0HN6je2wcHTmLsi8SAVGURfvuPyAiMt5X0tqXwBc49LJsoxgoKTTxd2jrz5CytCA1bMmxfhruFbzFrv6tp_XfDvmd0HO4cTqo4oq7WsBQBJZjWZ2NfmBPRHJHZ1IUeN2f4lo4y7sikrtrq6mQl3Kl6m60plwUe5bs0giU9q44jXyeX2O5SezhLZaftrNG5e_YSN26Tdaaf3d6ANj2yfGPolbKuZmeIs3DRo8wrNSfl7QmexZ7tP2nB2fMk66BMd3HcsrmyfUB2x_7_PrujlawYfy-ipkp8McsFCWKgFmaDIJV3H46GCY_ytuSWclo4Z_FrSXpEdgEFbzLYzWS0]--></g></svg>

<p><strong><em>什么时候引用计数加一呢？</em></strong> 调用<code>CloseableReference</code>子类clone方法克隆一个新的CloseableReference时，就等价于增加了一个使用者，应用计数就会加一。 新和旧的CloseableReference持有同一个SharedReference实例。</p>
<p><strong><em>BitmapPool</em></strong> 不会无限扩张，最大支持多少个Bitmap？是否有清理策略？</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="543px" preserveAspectRatio="none" style="width:960px;height:543px;background:#FFFFFF;" version="1.1" viewBox="0 0 960 543" width="960px" zoomAndPan="magnify"><defs/><g><!--class SharedReference--><g id="elem_SharedReference"><rect codeLine="1" fill="#F1F1F1" height="96.8906" id="SharedReference" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="361" x="588" y="331"/><ellipse cx="678.25" cy="347" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M680.5938,342.6719 C679.6563,342.2344 679.0625,342.0938 678.1875,342.0938 C675.5625,342.0938 673.5625,344.1719 673.5625,346.8906 L673.5625,348.0156 C673.5625,350.5938 675.6719,352.4844 678.5625,352.4844 C679.7813,352.4844 680.9375,352.1875 681.6875,351.6406 C682.2656,351.2344 682.5938,350.7813 682.5938,350.3906 C682.5938,349.9375 682.2031,349.5469 681.7344,349.5469 C681.5156,349.5469 681.3125,349.625 681.125,349.8125 C680.6719,350.2969 680.6719,350.2969 680.4844,350.3906 C680.0625,350.6563 679.375,350.7813 678.6094,350.7813 C676.5625,350.7813 675.2656,349.6875 675.2656,347.9844 L675.2656,346.8906 C675.2656,345.1094 676.5156,343.7969 678.25,343.7969 C678.8281,343.7969 679.4375,343.9531 679.9063,344.2031 C680.3906,344.4844 680.5625,344.7031 680.6563,345.1094 C680.7188,345.5156 680.75,345.6406 680.8906,345.7656 C681.0313,345.9063 681.2656,346.0156 681.4844,346.0156 C681.75,346.0156 682.0156,345.875 682.1875,345.6563 C682.2969,345.5 682.3281,345.3125 682.3281,344.8906 L682.3281,343.4688 C682.3281,343.0313 682.3125,342.9063 682.2188,342.75 C682.0625,342.4844 681.7813,342.3438 681.4844,342.3438 C681.1875,342.3438 680.9844,342.4375 680.7656,342.75 L680.5938,342.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="125" x="698.75" y="351.8467">SharedReference</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="45" x="907" y="328"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="43" x="908" y="340.1387">Bitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="589" x2="948" y1="363" y2="363"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="110" x="594" y="379.9951">Bitmap mValue</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="106" x="594" y="396.292">int mRefCount</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="349" x="594" y="412.5889">ResourceReleaser&lt;Bitmap&gt; mResourceReleaser</text><line style="stroke:#181818;stroke-width:0.5;" x1="589" x2="948" y1="419.8906" y2="419.8906"/></g><!--class Bitmap--><g id="elem_Bitmap"><rect fill="#F1F1F1" height="48" id="Bitmap" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="85" x="529" y="223"/><ellipse cx="544" cy="239" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M546.3438,234.6719 C545.4063,234.2344 544.8125,234.0938 543.9375,234.0938 C541.3125,234.0938 539.3125,236.1719 539.3125,238.8906 L539.3125,240.0156 C539.3125,242.5938 541.4219,244.4844 544.3125,244.4844 C545.5313,244.4844 546.6875,244.1875 547.4375,243.6406 C548.0156,243.2344 548.3438,242.7813 548.3438,242.3906 C548.3438,241.9375 547.9531,241.5469 547.4844,241.5469 C547.2656,241.5469 547.0625,241.625 546.875,241.8125 C546.4219,242.2969 546.4219,242.2969 546.2344,242.3906 C545.8125,242.6563 545.125,242.7813 544.3594,242.7813 C542.3125,242.7813 541.0156,241.6875 541.0156,239.9844 L541.0156,238.8906 C541.0156,237.1094 542.2656,235.7969 544,235.7969 C544.5781,235.7969 545.1875,235.9531 545.6563,236.2031 C546.1406,236.4844 546.3125,236.7031 546.4063,237.1094 C546.4688,237.5156 546.5,237.6406 546.6406,237.7656 C546.7813,237.9063 547.0156,238.0156 547.2344,238.0156 C547.5,238.0156 547.7656,237.875 547.9375,237.6563 C548.0469,237.5 548.0781,237.3125 548.0781,236.8906 L548.0781,235.4688 C548.0781,235.0313 548.0625,234.9063 547.9688,234.75 C547.8125,234.4844 547.5313,234.3438 547.2344,234.3438 C546.9375,234.3438 546.7344,234.4375 546.5156,234.75 L546.3438,234.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="53" x="558" y="243.8467">Bitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="530" x2="613" y1="255" y2="255"/><line style="stroke:#181818;stroke-width:0.5;" x1="530" x2="613" y1="263" y2="263"/></g><!--class CloseableReference--><g id="elem_CloseableReference"><rect codeLine="7" fill="#F1F1F1" height="48" id="CloseableReference" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="223" x="330" y="355.5"/><ellipse cx="345" cy="371.5" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M347.0781,373.3125 L347.4688,374.2969 L347.0781,374.2969 C346.625,374.2969 346.5156,374.3125 346.3594,374.4219 C346.1094,374.5781 345.9531,374.8594 345.9531,375.1563 C345.9531,375.4219 346.0938,375.6719 346.3125,375.8281 C346.4531,375.9531 346.6563,376 347.0781,376 L349.4375,376 C349.7969,376 350.0156,375.9688 350.1563,375.875 C350.4063,375.7344 350.5625,375.4375 350.5625,375.1563 C350.5625,374.875 350.4219,374.625 350.2031,374.4688 C350.0313,374.3281 349.875,374.2969 349.4063,374.2969 L346.0156,366.0938 L342.3438,366.0938 C341.8906,366.0938 341.7656,366.1094 341.6094,366.2031 C341.3594,366.375 341.2031,366.6563 341.2031,366.9375 C341.2031,367.2188 341.3438,367.4688 341.5625,367.6406 C341.7344,367.75 341.9063,367.7813 342.3438,367.7813 L343.4219,367.7813 L340.7813,374.2969 C340.3594,374.2969 340.2031,374.3125 340.0469,374.4219 C339.7969,374.5781 339.6406,374.8594 339.6406,375.1563 C339.6406,375.7188 340.0156,376 340.7656,376 L343.0313,376 C343.3906,376 343.6094,375.9688 343.7344,375.875 C344,375.7344 344.1406,375.4375 344.1406,375.1563 C344.1406,374.875 344.0156,374.625 343.7969,374.4531 C343.625,374.3281 343.4844,374.2969 343.0313,374.2969 L342.6406,374.2969 L343.0313,373.3125 L347.0781,373.3125 Z M346.375,371.6094 L343.7031,371.6094 L345.0469,368.3438 L346.375,371.6094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="144" x="359" y="376.3467">CloseableReference</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="45" x="511" y="352.5"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="43" x="512" y="364.6387">Bitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="331" x2="552" y1="387.5" y2="387.5"/><line style="stroke:#181818;stroke-width:0.5;" x1="331" x2="552" y1="395.5" y2="395.5"/></g><!--class DefaultCloseableReference--><g id="elem_DefaultCloseableReference"><rect codeLine="8" fill="#F1F1F1" height="48" id="DefaultCloseableReference" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="277" x="321" y="488"/><ellipse cx="336" cy="504" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M338.3438,499.6719 C337.4063,499.2344 336.8125,499.0938 335.9375,499.0938 C333.3125,499.0938 331.3125,501.1719 331.3125,503.8906 L331.3125,505.0156 C331.3125,507.5938 333.4219,509.4844 336.3125,509.4844 C337.5313,509.4844 338.6875,509.1875 339.4375,508.6406 C340.0156,508.2344 340.3438,507.7813 340.3438,507.3906 C340.3438,506.9375 339.9531,506.5469 339.4844,506.5469 C339.2656,506.5469 339.0625,506.625 338.875,506.8125 C338.4219,507.2969 338.4219,507.2969 338.2344,507.3906 C337.8125,507.6563 337.125,507.7813 336.3594,507.7813 C334.3125,507.7813 333.0156,506.6875 333.0156,504.9844 L333.0156,503.8906 C333.0156,502.1094 334.2656,500.7969 336,500.7969 C336.5781,500.7969 337.1875,500.9531 337.6563,501.2031 C338.1406,501.4844 338.3125,501.7031 338.4063,502.1094 C338.4688,502.5156 338.5,502.6406 338.6406,502.7656 C338.7813,502.9063 339.0156,503.0156 339.2344,503.0156 C339.5,503.0156 339.7656,502.875 339.9375,502.6563 C340.0469,502.5 340.0781,502.3125 340.0781,501.8906 L340.0781,500.4688 C340.0781,500.0313 340.0625,499.9063 339.9688,499.75 C339.8125,499.4844 339.5313,499.3438 339.2344,499.3438 C338.9375,499.3438 338.7344,499.4375 338.5156,499.75 L338.3438,499.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="198" x="350" y="508.8467">DefaultCloseableReference</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="45" x="556" y="485"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="43" x="557" y="497.1387">Bitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="322" x2="597" y1="520" y2="520"/><line style="stroke:#181818;stroke-width:0.5;" x1="322" x2="597" y1="528" y2="528"/></g><!--class CloseableImage--><g id="elem_CloseableImage"><rect codeLine="12" fill="#F1F1F1" height="48" id="CloseableImage" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="147" x="118" y="7"/><ellipse cx="133" cy="23" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M133.9531,19.7813 L135.6719,19.7813 C136.0625,19.7813 136.25,19.75 136.375,19.6719 C136.6406,19.5156 136.7813,19.2344 136.7813,18.9375 C136.7813,18.6719 136.6719,18.4063 136.4375,18.2344 C136.2656,18.125 136.125,18.0938 135.6719,18.0938 L130.5313,18.0938 C130.0938,18.0938 129.9688,18.1094 129.8125,18.2031 C129.5625,18.3594 129.4063,18.6563 129.4063,18.9375 C129.4063,19.2188 129.5469,19.4688 129.7656,19.6406 C129.9219,19.75 130.1094,19.7813 130.5313,19.7813 L132.25,19.7813 L132.25,26.2969 L130.5313,26.2969 C130.0938,26.2969 129.9688,26.3125 129.8125,26.4219 C129.5625,26.5781 129.4063,26.8594 129.4063,27.1563 C129.4063,27.4063 129.5469,27.6719 129.7656,27.8281 C129.9219,27.9531 130.125,28 130.5313,28 L135.6719,28 C136.4219,28 136.7813,27.7188 136.7813,27.1563 C136.7813,26.875 136.6719,26.625 136.4375,26.4531 C136.2656,26.3281 136.125,26.2969 135.6719,26.2969 L133.9531,26.2969 L133.9531,19.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="115" x="147" y="27.8467">CloseableImage</text><line style="stroke:#181818;stroke-width:0.5;" x1="119" x2="264" y1="39" y2="39"/><line style="stroke:#181818;stroke-width:0.5;" x1="119" x2="264" y1="47" y2="47"/></g><!--class CloseableBitmap--><g id="elem_CloseableBitmap"><rect codeLine="13" fill="#F1F1F1" height="48" id="CloseableBitmap" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="153" x="14" y="115"/><ellipse cx="29" cy="131" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M29.9531,127.7813 L31.6719,127.7813 C32.0625,127.7813 32.25,127.75 32.375,127.6719 C32.6406,127.5156 32.7813,127.2344 32.7813,126.9375 C32.7813,126.6719 32.6719,126.4063 32.4375,126.2344 C32.2656,126.125 32.125,126.0938 31.6719,126.0938 L26.5313,126.0938 C26.0938,126.0938 25.9688,126.1094 25.8125,126.2031 C25.5625,126.3594 25.4063,126.6563 25.4063,126.9375 C25.4063,127.2188 25.5469,127.4688 25.7656,127.6406 C25.9219,127.75 26.1094,127.7813 26.5313,127.7813 L28.25,127.7813 L28.25,134.2969 L26.5313,134.2969 C26.0938,134.2969 25.9688,134.3125 25.8125,134.4219 C25.5625,134.5781 25.4063,134.8594 25.4063,135.1563 C25.4063,135.4063 25.5469,135.6719 25.7656,135.8281 C25.9219,135.9531 26.125,136 26.5313,136 L31.6719,136 C32.4219,136 32.7813,135.7188 32.7813,135.1563 C32.7813,134.875 32.6719,134.625 32.4375,134.4531 C32.2656,134.3281 32.125,134.2969 31.6719,134.2969 L29.9531,134.2969 L29.9531,127.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="121" x="43" y="135.8467">CloseableBitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="15" x2="166" y1="147" y2="147"/><line style="stroke:#181818;stroke-width:0.5;" x1="15" x2="166" y1="155" y2="155"/></g><!--class CloseableStaticBitmap--><g id="elem_CloseableStaticBitmap"><rect codeLine="14" fill="#F1F1F1" height="48" id="CloseableStaticBitmap" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="193" x="7" y="223"/><ellipse cx="22" cy="239" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M22.9531,235.7813 L24.6719,235.7813 C25.0625,235.7813 25.25,235.75 25.375,235.6719 C25.6406,235.5156 25.7813,235.2344 25.7813,234.9375 C25.7813,234.6719 25.6719,234.4063 25.4375,234.2344 C25.2656,234.125 25.125,234.0938 24.6719,234.0938 L19.5313,234.0938 C19.0938,234.0938 18.9688,234.1094 18.8125,234.2031 C18.5625,234.3594 18.4063,234.6563 18.4063,234.9375 C18.4063,235.2188 18.5469,235.4688 18.7656,235.6406 C18.9219,235.75 19.1094,235.7813 19.5313,235.7813 L21.25,235.7813 L21.25,242.2969 L19.5313,242.2969 C19.0938,242.2969 18.9688,242.3125 18.8125,242.4219 C18.5625,242.5781 18.4063,242.8594 18.4063,243.1563 C18.4063,243.4063 18.5469,243.6719 18.7656,243.8281 C18.9219,243.9531 19.125,244 19.5313,244 L24.6719,244 C25.4219,244 25.7813,243.7188 25.7813,243.1563 C25.7813,242.875 25.6719,242.625 25.4375,242.4531 C25.2656,242.3281 25.125,242.2969 24.6719,242.2969 L22.9531,242.2969 L22.9531,235.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="161" x="36" y="243.8467">CloseableStaticBitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="199" y1="255" y2="255"/><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="199" y1="263" y2="263"/></g><!--class BaseCloseableImage--><g id="elem_BaseCloseableImage"><rect codeLine="17" fill="#F1F1F1" height="48" id="BaseCloseableImage" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="182" x="202.5" y="115"/><ellipse cx="217.5" cy="131" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M219.5781,132.8125 L219.9688,133.7969 L219.5781,133.7969 C219.125,133.7969 219.0156,133.8125 218.8594,133.9219 C218.6094,134.0781 218.4531,134.3594 218.4531,134.6563 C218.4531,134.9219 218.5938,135.1719 218.8125,135.3281 C218.9531,135.4531 219.1563,135.5 219.5781,135.5 L221.9375,135.5 C222.2969,135.5 222.5156,135.4688 222.6563,135.375 C222.9063,135.2344 223.0625,134.9375 223.0625,134.6563 C223.0625,134.375 222.9219,134.125 222.7031,133.9688 C222.5313,133.8281 222.375,133.7969 221.9063,133.7969 L218.5156,125.5938 L214.8438,125.5938 C214.3906,125.5938 214.2656,125.6094 214.1094,125.7031 C213.8594,125.875 213.7031,126.1563 213.7031,126.4375 C213.7031,126.7188 213.8438,126.9688 214.0625,127.1406 C214.2344,127.25 214.4063,127.2813 214.8438,127.2813 L215.9219,127.2813 L213.2813,133.7969 C212.8594,133.7969 212.7031,133.8125 212.5469,133.9219 C212.2969,134.0781 212.1406,134.3594 212.1406,134.6563 C212.1406,135.2188 212.5156,135.5 213.2656,135.5 L215.5313,135.5 C215.8906,135.5 216.1094,135.4688 216.2344,135.375 C216.5,135.2344 216.6406,134.9375 216.6406,134.6563 C216.6406,134.375 216.5156,134.125 216.2969,133.9531 C216.125,133.8281 215.9844,133.7969 215.5313,133.7969 L215.1406,133.7969 L215.5313,132.8125 L219.5781,132.8125 Z M218.875,131.1094 L216.2031,131.1094 L217.5469,127.8438 L218.875,131.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="150" x="231.5" y="135.8467">BaseCloseableImage</text><line style="stroke:#181818;stroke-width:0.5;" x1="203.5" x2="383.5" y1="147" y2="147"/><line style="stroke:#181818;stroke-width:0.5;" x1="203.5" x2="383.5" y1="155" y2="155"/></g><!--class BaseCloseableStaticBitmap--><g id="elem_BaseCloseableStaticBitmap"><rect fill="#F1F1F1" height="48" id="BaseCloseableStaticBitmap" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="232" x="62.5" y="355.5"/><ellipse cx="77.5" cy="371.5" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M79.8438,367.1719 C78.9063,366.7344 78.3125,366.5938 77.4375,366.5938 C74.8125,366.5938 72.8125,368.6719 72.8125,371.3906 L72.8125,372.5156 C72.8125,375.0938 74.9219,376.9844 77.8125,376.9844 C79.0313,376.9844 80.1875,376.6875 80.9375,376.1406 C81.5156,375.7344 81.8438,375.2813 81.8438,374.8906 C81.8438,374.4375 81.4531,374.0469 80.9844,374.0469 C80.7656,374.0469 80.5625,374.125 80.375,374.3125 C79.9219,374.7969 79.9219,374.7969 79.7344,374.8906 C79.3125,375.1563 78.625,375.2813 77.8594,375.2813 C75.8125,375.2813 74.5156,374.1875 74.5156,372.4844 L74.5156,371.3906 C74.5156,369.6094 75.7656,368.2969 77.5,368.2969 C78.0781,368.2969 78.6875,368.4531 79.1563,368.7031 C79.6406,368.9844 79.8125,369.2031 79.9063,369.6094 C79.9688,370.0156 80,370.1406 80.1406,370.2656 C80.2813,370.4063 80.5156,370.5156 80.7344,370.5156 C81,370.5156 81.2656,370.375 81.4375,370.1563 C81.5469,370 81.5781,369.8125 81.5781,369.3906 L81.5781,367.9688 C81.5781,367.5313 81.5625,367.4063 81.4688,367.25 C81.3125,366.9844 81.0313,366.8438 80.7344,366.8438 C80.4375,366.8438 80.2344,366.9375 80.0156,367.25 L79.8438,367.1719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="200" x="91.5" y="376.3467">BaseCloseableStaticBitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="63.5" x2="293.5" y1="387.5" y2="387.5"/><line style="stroke:#181818;stroke-width:0.5;" x1="63.5" x2="293.5" y1="395.5" y2="395.5"/></g><!--class DefaultCloseableStaticBitmap--><g id="elem_DefaultCloseableStaticBitmap"><rect fill="#F1F1F1" height="48" id="DefaultCloseableStaticBitmap" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="251" x="35" y="488"/><ellipse cx="50" cy="504" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M52.3438,499.6719 C51.4063,499.2344 50.8125,499.0938 49.9375,499.0938 C47.3125,499.0938 45.3125,501.1719 45.3125,503.8906 L45.3125,505.0156 C45.3125,507.5938 47.4219,509.4844 50.3125,509.4844 C51.5313,509.4844 52.6875,509.1875 53.4375,508.6406 C54.0156,508.2344 54.3438,507.7813 54.3438,507.3906 C54.3438,506.9375 53.9531,506.5469 53.4844,506.5469 C53.2656,506.5469 53.0625,506.625 52.875,506.8125 C52.4219,507.2969 52.4219,507.2969 52.2344,507.3906 C51.8125,507.6563 51.125,507.7813 50.3594,507.7813 C48.3125,507.7813 47.0156,506.6875 47.0156,504.9844 L47.0156,503.8906 C47.0156,502.1094 48.2656,500.7969 50,500.7969 C50.5781,500.7969 51.1875,500.9531 51.6563,501.2031 C52.1406,501.4844 52.3125,501.7031 52.4063,502.1094 C52.4688,502.5156 52.5,502.6406 52.6406,502.7656 C52.7813,502.9063 53.0156,503.0156 53.2344,503.0156 C53.5,503.0156 53.7656,502.875 53.9375,502.6563 C54.0469,502.5 54.0781,502.3125 54.0781,501.8906 L54.0781,500.4688 C54.0781,500.0313 54.0625,499.9063 53.9688,499.75 C53.8125,499.4844 53.5313,499.3438 53.2344,499.3438 C52.9375,499.3438 52.7344,499.4375 52.5156,499.75 L52.3438,499.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="219" x="64" y="508.8467">DefaultCloseableStaticBitmap</text><line style="stroke:#181818;stroke-width:0.5;" x1="36" x2="285" y1="520" y2="520"/><line style="stroke:#181818;stroke-width:0.5;" x1="36" x2="285" y1="528" y2="528"/></g><!--reverse link SharedReference to Bitmap--><g id="link_SharedReference_Bitmap"><path codeLine="6" d="M686.554,324.2158 C655.761,303.8168 631.23,287.567 606.266,271.03 " fill="none" id="SharedReference-backto-Bitmap" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="696.558,330.843,693.7651,324.1947,686.554,324.2158,689.3469,330.8641,696.558,330.843" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CloseableReference to DefaultCloseableReference--><g id="link_CloseableReference_DefaultCloseableReference"><path codeLine="9" d="M447.1364,421.3612 C450.4064,445.0692 453.014,463.9771 456.295,487.7609 " fill="none" id="CloseableReference-backto-DefaultCloseableReference" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="444.677,403.53,441.1927,422.181,453.0802,420.5414,444.677,403.53" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CloseableReference to SharedReference--><g id="link_CloseableReference_SharedReference"><path codeLine="10" d="M565.268,379.5 C576.758,379.5 576.248,379.5 587.738,379.5 " fill="none" id="CloseableReference-backto-SharedReference" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="553.268,379.5,559.268,383.5,565.268,379.5,559.268,375.5,553.268,379.5" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CloseableImage to CloseableBitmap--><g id="link_CloseableImage_CloseableBitmap"><path codeLine="15" d="M157.1678,68.0312 C140.3418,85.6892 129.622,96.941 112.722,114.678 " fill="none" id="CloseableImage-backto-CloseableBitmap" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="169.585,55,152.824,63.8921,161.5115,72.1703,169.585,55" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CloseableBitmap to CloseableStaticBitmap--><g id="link_CloseableBitmap_CloseableStaticBitmap"><path codeLine="16" d="M95.5119,180.8661 C97.6775,198.5241 98.4644,204.941 100.6398,222.678 " fill="none" id="CloseableBitmap-backto-CloseableStaticBitmap" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="93.3208,163,89.5565,181.5965,101.4673,180.1358,93.3208,163" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CloseableImage to BaseCloseableImage--><g id="link_CloseableImage_BaseCloseableImage"><path codeLine="18" d="M226.113,67.9702 C243.105,85.6282 253.99,96.941 271.058,114.678 " fill="none" id="CloseableImage-backto-BaseCloseableImage" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="213.632,55,221.7896,72.1305,230.4364,63.8098,213.632,55" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CloseableStaticBitmap to BaseCloseableStaticBitmap--><g id="link_CloseableStaticBitmap_BaseCloseableStaticBitmap"><path codeLine="19" d="M125.705,286.6363 C139.33,310.3443 151.475,331.477 165.144,355.261 " fill="none" id="CloseableStaticBitmap-backto-BaseCloseableStaticBitmap" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="116.736,271.03,120.5029,289.626,130.9071,283.6467,116.736,271.03" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BaseCloseableImage to BaseCloseableStaticBitmap--><g id="link_BaseCloseableImage_BaseCloseableStaticBitmap"><path codeLine="20" d="M274.446,179.5165 C252.404,225.2285 211.554,309.949 189.612,355.454 " fill="none" id="BaseCloseableImage-backto-BaseCloseableStaticBitmap" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="282.264,163.303,269.0415,176.9105,279.8505,182.1225,282.264,163.303" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BaseCloseableStaticBitmap to DefaultCloseableStaticBitmap--><g id="link_BaseCloseableStaticBitmap_DefaultCloseableStaticBitmap"><path codeLine="21" d="M172.8636,421.3612 C169.5936,445.0692 166.986,463.9771 163.705,487.7609 " fill="none" id="BaseCloseableStaticBitmap-backto-DefaultCloseableStaticBitmap" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="175.323,403.53,166.9198,420.5414,178.8073,422.181,175.323,403.53" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BaseCloseableStaticBitmap to CloseableReference--><g id="link_BaseCloseableStaticBitmap_CloseableReference"><path codeLine="22" d="M306.59,379.5 C318.354,379.5 318.118,379.5 329.883,379.5 " fill="none" id="BaseCloseableStaticBitmap-backto-CloseableReference" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="294.59,379.5,300.59,383.5,306.59,379.5,300.59,375.5,294.59,379.5" style="stroke:#181818;stroke-width:1.0;"/></g><!--link Bitmap to BaseCloseableStaticBitmap--><g id="link_Bitmap_BaseCloseableStaticBitmap"><path codeLine="23" d="M528.747,261.261 C477.29,277.324 388.334,305.415 312.5,331 C289.581,338.733 275.8766,343.4804 253.7366,351.3644 " fill="none" id="Bitmap-to-BaseCloseableStaticBitmap" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="242.432,355.39,249.4262,357.1454,253.7366,351.3644,246.7425,349.609,242.432,355.39" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[bLAz3e8m4Dxx59rDU0FY02wkaBWVzVX9MZ3jTLBVtGQGo569Thj-VzUxAWtEoR85YzS2QxJOAqopZWpSZl8kP3XJ9Sq5jCVnfkj9ca3F1z_JU5EW6xnLMA16S6WN2yCHyHGiJXwIP0uHK3coe4YgiR5S3mwXqhZfJKo44zRWDUtmjf1C7o7mgpAcE2IsQrfA-AI42AD0MqFWBBApWGPZmFp6258IKATcV6qqTSizMCr8ApisqYmiWRKQ2zoZVTf7sAlqhSzVYcqKtzkFscM3aONlgVpj_JTV]--></g></svg>

<p><code>com.facebook.imagepipeline.memory.DefaultNativeMemoryChunkPoolParams#get</code></p>
<h3 id="解码的临时缓存"><a href="#解码的临时缓存" class="headerlink" title="解码的临时缓存"></a>解码的临时缓存</h3><p>DefaultDecoder在解码图片生成BitMap时可以设置临时缓存，防止频繁GC，通过<code>android.graphics.BitmapFactory.Options#inTempStorage</code>来设置图片解码临时缓存，api文档中临时缓存大小建议为16K左右。临时缓存使用Pools.Pool&lt;ByteBuffer&gt;，是<code>SynchronizedPool</code>，缓存的个数默认是java虚拟机可使用的处理器个数<small>（可等同于cpu的核心数，但不是完全对等）</small>。这个是解码器独用的内存池，在Java堆上申请内存。</p>
<figure class="highlight kotlin"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// PlatformDecoderFactory.kt</span></span><br><span class="line">  <span class="function"><span class="keyword">fun</span> <span class="title">createPool</span><span class="params">(poolFactory: <span class="type">PoolFactory</span>, useDecodeBufferHelper: <span class="type">Boolean</span>)</span></span>: Pools.Pool&lt;ByteBuffer&gt; &#123;</span><br><span class="line">    <span class="keyword">if</span> (useDecodeBufferHelper) &#123;</span><br><span class="line">      <span class="keyword">return</span> DecodeBufferHelper.INSTANCE</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">val</span> maxNumThreads = poolFactory.flexByteArrayPoolMaxNumThreads</span><br><span class="line">    <span class="keyword">val</span> pool: Pools.Pool&lt;ByteBuffer&gt; = SynchronizedPool(maxNumThreads)</span><br><span class="line">    <span class="keyword">for</span> (i <span class="keyword">in</span> <span class="number">0</span> until maxNumThreads) &#123;</span><br><span class="line">      <span class="comment">//release这个函数含义是：将实例释放到缓存池中，提供给后续使用。</span></span><br><span class="line">      <span class="comment">//每个buffer的默认大小是16K</span></span><br><span class="line">      pool.release(ByteBuffer.allocate(DecodeBufferHelper.getRecommendedDecodeBufferSize()))</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> pool</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<h2 id="图片处理生产者序列"><a href="#图片处理生产者序列" class="headerlink" title="图片处理生产者序列"></a>图片处理生产者序列</h2><p>Fresco从一个图片的URL下载图片并解码成Bitmap需要经过一个生产者序列的处理。在<code>ImagePipeline#fetchDecodedImage</code>中开始生成队列并执行任务序列。下图展示了图片处理的所有生产者，其中有些序列默认是不使用的，除非进行特别配置或者特定场景。图中箭头的方向是图片数据流动的方向，而调用顺序正好相反，后面的Producer持有前面的Producer，当然这个持有只是对Producer接口的依赖，并不是直接依赖实现类。</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="447px" preserveAspectRatio="none" style="width:1091px;height:447px;background:#FFFFFF;" version="1.1" viewBox="0 0 1091 447" width="1091px" zoomAndPan="magnify"><defs/><g><!--entity ????--><g id="elem_&#22270;&#29255;&#25968;&#25454;"><ellipse cx="137.5" cy="25" fill="#F1F1F1" rx="8" ry="8" style="stroke:#181818;stroke-width:0.5;"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="56" x="109.5" y="54.9951">&#22270;&#29255;&#25968;&#25454;</text></g><!--entity NetworkFetchProducer--><g id="elem_NetworkFetchProducer"><rect fill="#F1F1F1" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="186" x="181.5" y="7"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="166" x="191.5" y="29.9951">NetworkFetchProducer</text></g><!--entity WebpTranscodeProducer--><g id="elem_WebpTranscodeProducer"><rect fill="#FFFFFF" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:1.0,3.0;" width="201" x="403" y="7"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="181" x="413" y="29.9951">WebpTranscodeProducer</text></g><!--entity PartialDiskCacheProducer--><g id="elem_PartialDiskCacheProducer"><rect fill="#FFFFFF" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:1.0,3.0;" width="205" x="639" y="7"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="185" x="649" y="29.9951">PartialDiskCacheProducer</text></g><!--entity DiskCacheWriteProducer--><g id="elem_DiskCacheWriteProducer"><rect fill="#F1F1F1" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="199" x="879" y="7"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="179" x="889" y="29.9951">DiskCacheWriteProducer</text></g><!--entity DiskCacheReadProducer--><g id="elem_DiskCacheReadProducer"><rect fill="#F1F1F1" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="195" x="881" y="103"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="175" x="891" y="125.9951">DiskCacheReadProducer</text></g><!--entity EncodedMemoryCacheProducer--><g id="elem_EncodedMemoryCacheProducer"><rect fill="#F1F1F1" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="248" x="597.5" y="103"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="228" x="607.5" y="125.9951">EncodedMemoryCacheProducer</text></g><!--entity EncodedProbeProducer--><g id="elem_EncodedProbeProducer"><rect fill="#FFFFFF" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:1.0,3.0;" width="189" x="373" y="103"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="169" x="383" y="125.9951">EncodedProbeProducer</text></g><!--entity EncodedCacheKeyMultiplexProducer--><g id="elem_EncodedCacheKeyMultiplexProducer"><rect fill="#F1F1F1" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="283" x="55" y="103"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="263" x="65" y="125.9951">EncodedCacheKeyMultiplexProducer</text></g><!--entity AddImageTransformMetaDataProducer--><g id="elem_AddImageTransformMetaDataProducer"><rect fill="#F1F1F1" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="300" x="46.5" y="199"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="280" x="56.5" y="221.9951">AddImageTransformMetaDataProducer</text></g><!--entity ResizeAndRotateProducer--><g id="elem_ResizeAndRotateProducer"><rect fill="#F1F1F1" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="209" x="382" y="199"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="189" x="392" y="221.9951">ResizeAndRotateProducer</text></g><!--entity DecodeProducer--><g id="elem_DecodeProducer"><rect fill="#F1F1F1" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="139" x="626" y="199"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="119" x="636" y="221.9951">DecodeProducer</text></g><!--entity BitmapMemoryCacheProducer--><g id="elem_BitmapMemoryCacheProducer"><rect fill="#F1F1F1" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="239" x="800" y="199"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="219" x="810" y="221.9951">BitmapMemoryCacheProducer</text></g><!--entity BitmapMemoryCacheKeyMultiplexProducer--><g id="elem_BitmapMemoryCacheKeyMultiplexProducer"><rect fill="#F1F1F1" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="332" x="753.5" y="295"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="312" x="763.5" y="317.9951">BitmapMemoryCacheKeyMultiplexProducer</text></g><!--entity ThreadHandoffProducer--><g id="elem_ThreadHandoffProducer"><rect fill="#F1F1F1" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="191" x="527" y="295"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="171" x="537" y="317.9951">ThreadHandoffProducer</text></g><!--entity BitmapMemoryCacheGetProducer--><g id="elem_BitmapMemoryCacheGetProducer"><rect fill="#F1F1F1" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="266" x="225.5" y="295"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="246" x="235.5" y="317.9951">BitmapMemoryCacheGetProducer</text></g><!--entity BitmapProbeProducer--><g id="elem_BitmapProbeProducer"><rect fill="#FFFFFF" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:1.0,3.0;" width="180" x="10.5" y="295"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="160" x="20.5" y="317.9951">BitmapProbeProducer</text></g><!--entity PostprocessorProducer--><g id="elem_PostprocessorProducer"><rect fill="#FFFFFF" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:1.0,3.0;" width="187" x="7" y="391"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="167" x="17" y="413.9951">PostprocessorProducer</text></g><!--entity PostprocessedBitmapMemoryCacheProducer--><g id="elem_PostprocessedBitmapMemoryCacheProducer"><rect fill="#FFFFFF" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:1.0,3.0;" width="345" x="229" y="391"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="325" x="239" y="413.9951">PostprocessedBitmapMemoryCacheProducer</text></g><!--entity BitmapPrepareProducer--><g id="elem_BitmapPrepareProducer"><rect fill="#F1F1F1" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="194" x="609.5" y="391"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="174" x="619.5" y="413.9951">BitmapPrepareProducer</text></g><!--entity DelayProducer--><g id="elem_DelayProducer"><rect fill="#FFFFFF" height="36.2969" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:1.0,3.0;" width="124" x="838.5" y="391"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="104" x="848.5" y="413.9951">DelayProducer</text></g><!--entity Bitmap--><g id="elem_Bitmap"><ellipse cx="1006.5" cy="409" fill="#F1F1F1" rx="8" ry="8" style="stroke:#181818;stroke-width:0.5;"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="53" x="980" y="438.9951">Bitmap</text></g><!--link ???? to NetworkFetchProducer--><g id="link_&#22270;&#29255;&#25968;&#25454;_NetworkFetchProducer"><path d="M146.598,25 C158.089,25 163.58,25 175.071,25 " fill="none" id="&#22270;&#29255;&#25968;&#25454;-to-NetworkFetchProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="181.071,25,172.071,21,176.071,25,172.071,29,181.071,25" style="stroke:#181818;stroke-width:1.0;"/></g><!--link NetworkFetchProducer to WebpTranscodeProducer--><g id="link_NetworkFetchProducer_WebpTranscodeProducer"><path d="M367.531,25 C379.305,25 385.078,25 396.851,25 " fill="none" id="NetworkFetchProducer-to-WebpTranscodeProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="402.851,25,393.851,21,397.851,25,393.851,29,402.851,25" style="stroke:#181818;stroke-width:1.0;"/></g><!--link WebpTranscodeProducer to PartialDiskCacheProducer--><g id="link_WebpTranscodeProducer_PartialDiskCacheProducer"><path d="M604.371,25 C615.888,25 621.404,25 632.921,25 " fill="none" id="WebpTranscodeProducer-to-PartialDiskCacheProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="638.921,25,629.921,21,633.921,25,629.921,29,638.921,25" style="stroke:#181818;stroke-width:1.0;"/></g><!--link PartialDiskCacheProducer to DiskCacheWriteProducer--><g id="link_PartialDiskCacheProducer_DiskCacheWriteProducer"><path d="M844.262,25 C855.798,25 861.334,25 872.87,25 " fill="none" id="PartialDiskCacheProducer-to-DiskCacheWriteProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="878.87,25,869.87,21,873.87,25,869.87,29,878.87,25" style="stroke:#181818;stroke-width:1.0;"/></g><!--link DiskCacheWriteProducer to DiskCacheReadProducer--><g id="link_DiskCacheWriteProducer_DiskCacheReadProducer"><path d="M978.5,43.241 C978.5,60.202 978.5,79.945 978.5,96.868 " fill="none" id="DiskCacheWriteProducer-to-DiskCacheReadProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="978.5,102.868,982.5,93.868,978.5,97.868,974.5,93.868,978.5,102.868" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link EncodedMemoryCacheProducer to DiskCacheReadProducer--><g id="link_EncodedMemoryCacheProducer_DiskCacheReadProducer"><path d="M851.733,121 C863.489,121 869.244,121 881,121 " fill="none" id="EncodedMemoryCacheProducer-backto-DiskCacheReadProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="845.733,121,854.733,125,850.733,121,854.733,117,845.733,121" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link EncodedProbeProducer to EncodedMemoryCacheProducer--><g id="link_EncodedProbeProducer_EncodedMemoryCacheProducer"><path d="M568.254,121 C579.969,121 585.685,121 597.4,121 " fill="none" id="EncodedProbeProducer-backto-EncodedMemoryCacheProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="562.254,121,571.254,125,567.254,121,571.254,117,562.254,121" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link EncodedCacheKeyMultiplexProducer to EncodedProbeProducer--><g id="link_EncodedCacheKeyMultiplexProducer_EncodedProbeProducer"><path d="M344.087,121 C355.714,121 361.341,121 372.968,121 " fill="none" id="EncodedCacheKeyMultiplexProducer-backto-EncodedProbeProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="338.087,121,347.087,125,343.087,121,347.087,117,338.087,121" style="stroke:#181818;stroke-width:1.0;"/></g><!--link EncodedCacheKeyMultiplexProducer to AddImageTransformMetaDataProducer--><g id="link_EncodedCacheKeyMultiplexProducer_AddImageTransformMetaDataProducer"><path d="M196.5,139.241 C196.5,156.202 196.5,175.945 196.5,192.868 " fill="none" id="EncodedCacheKeyMultiplexProducer-to-AddImageTransformMetaDataProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="196.5,198.868,200.5,189.868,196.5,193.868,192.5,189.868,196.5,198.868" style="stroke:#181818;stroke-width:1.0;"/></g><!--link AddImageTransformMetaDataProducer to ResizeAndRotateProducer--><g id="link_AddImageTransformMetaDataProducer_ResizeAndRotateProducer"><path d="M346.598,217 C358.347,217 364.097,217 375.846,217 " fill="none" id="AddImageTransformMetaDataProducer-to-ResizeAndRotateProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="381.846,217,372.846,213,376.846,217,372.846,221,381.846,217" style="stroke:#181818;stroke-width:1.0;"/></g><!--link ResizeAndRotateProducer to DecodeProducer--><g id="link_ResizeAndRotateProducer_DecodeProducer"><path d="M591,217 C602.566,217 608.132,217 619.697,217 " fill="none" id="ResizeAndRotateProducer-to-DecodeProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="625.697,217,616.697,213,620.697,217,616.697,221,625.697,217" style="stroke:#181818;stroke-width:1.0;"/></g><!--link DecodeProducer to BitmapMemoryCacheProducer--><g id="link_DecodeProducer_BitmapMemoryCacheProducer"><path d="M765.062,217 C776.625,217 782.188,217 793.751,217 " fill="none" id="DecodeProducer-to-BitmapMemoryCacheProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="799.751,217,790.751,213,794.751,217,790.751,221,799.751,217" style="stroke:#181818;stroke-width:1.0;"/></g><!--link BitmapMemoryCacheProducer to BitmapMemoryCacheKeyMultiplexProducer--><g id="link_BitmapMemoryCacheProducer_BitmapMemoryCacheKeyMultiplexProducer"><path d="M919.5,235.241 C919.5,252.202 919.5,271.945 919.5,288.868 " fill="none" id="BitmapMemoryCacheProducer-to-BitmapMemoryCacheKeyMultiplexProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="919.5,294.868,923.5,285.868,919.5,289.868,915.5,285.868,919.5,294.868" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link ThreadHandoffProducer to BitmapMemoryCacheKeyMultiplexProducer--><g id="link_ThreadHandoffProducer_BitmapMemoryCacheKeyMultiplexProducer"><path d="M724.213,313 C735.876,313 741.539,313 753.202,313 " fill="none" id="ThreadHandoffProducer-backto-BitmapMemoryCacheKeyMultiplexProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="718.213,313,727.213,317,723.213,313,727.213,309,718.213,313" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BitmapMemoryCacheGetProducer to ThreadHandoffProducer--><g id="link_BitmapMemoryCacheGetProducer_ThreadHandoffProducer"><path d="M497.531,313 C509.298,313 515.065,313 526.831,313 " fill="none" id="BitmapMemoryCacheGetProducer-backto-ThreadHandoffProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="491.531,313,500.531,317,496.531,313,500.531,309,491.531,313" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BitmapProbeProducer to BitmapMemoryCacheGetProducer--><g id="link_BitmapProbeProducer_BitmapMemoryCacheGetProducer"><path d="M196.699,313 C208.279,313 213.859,313 225.439,313 " fill="none" id="BitmapProbeProducer-backto-BitmapMemoryCacheGetProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="190.699,313,199.699,317,195.699,313,199.699,309,190.699,313" style="stroke:#181818;stroke-width:1.0;"/></g><!--link BitmapProbeProducer to PostprocessorProducer--><g id="link_BitmapProbeProducer_PostprocessorProducer"><path d="M100.5,331.241 C100.5,348.2017 100.5,367.9455 100.5,384.8683 " fill="none" id="BitmapProbeProducer-to-PostprocessorProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="100.5,390.8683,104.5,381.8683,100.5,385.8683,96.5,381.8683,100.5,390.8683" style="stroke:#181818;stroke-width:1.0;"/></g><!--link PostprocessorProducer to PostprocessedBitmapMemoryCacheProducer--><g id="link_PostprocessorProducer_PostprocessedBitmapMemoryCacheProducer"><path d="M194.269,409 C205.736,409 211.204,409 222.672,409 " fill="none" id="PostprocessorProducer-to-PostprocessedBitmapMemoryCacheProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="228.672,409,219.672,405,223.672,409,219.672,413,228.672,409" style="stroke:#181818;stroke-width:1.0;"/></g><!--link PostprocessedBitmapMemoryCacheProducer to BitmapPrepareProducer--><g id="link_PostprocessedBitmapMemoryCacheProducer_BitmapPrepareProducer"><path d="M574.254,409 C585.963,409 591.672,409 603.382,409 " fill="none" id="PostprocessedBitmapMemoryCacheProducer-to-BitmapPrepareProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="609.382,409,600.382,405,604.382,409,600.382,413,609.382,409" style="stroke:#181818;stroke-width:1.0;"/></g><!--link BitmapPrepareProducer to DelayProducer--><g id="link_BitmapPrepareProducer_DelayProducer"><path d="M803.879,409 C815.327,409 820.776,409 832.225,409 " fill="none" id="BitmapPrepareProducer-to-DelayProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="838.225,409,829.225,405,833.225,409,829.225,413,838.225,409" style="stroke:#181818;stroke-width:1.0;"/></g><!--link DelayProducer to Bitmap--><g id="link_DelayProducer_Bitmap"><path d="M962.609,409 C974.154,409 979.698,409 991.242,409 " fill="none" id="DelayProducer-to-Bitmap" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="997.242,409,988.242,405,992.242,409,988.242,413,997.242,409" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[bLHBJiCm4Dtd59PObmE0X5GeFw6YgbJgec8njITDbCIEdAbAk01YmP8LTq2SWDi0ro2VgasSE8JjpFjCteoJ1BwCGKF4k8fY9L7I7QKXCesSGAv2TBxUFd-UdxvVFxvVtjdWX2rkaJPA1nT8t9je9TOSzRspuxF579VnJ8DCk1AuGx239V3WQEFvXCUXB_5GA28KJhjWOTMkLFMQW2OVmf6V16V0lJvsbl5oFwkQqs6K4tVbkSxyAZHBWmrgh2c2Q2FLwcmGeaivxrpceuinHagdng2LRBQmhBViaqk7QiEwhkbOh4nM8Ng3wNWTaX-7-D1Ki4FAo8P2N4UmmcA1hjBH60b6G52H-XjJx6oAYV-8GoccYg2sD5kdN3NMZz4i5A1JdoA8MnVKqIi_iT6t9DOFjr_2pDFPELs15CfrAphjzJsluNE9r7fl9R3lkNNAckx6lLL_02gXM2kEIQ9qRrlpK8l7twfayKBHiKQhkMLOmxrBs-azH3KypFxnxV6DC8Jq7x7LbROFeYhXc98Pf2J_0W00]--></g></svg>

<h3 id="NetworkFetchProducer"><a href="#NetworkFetchProducer" class="headerlink" title="NetworkFetchProducer"></a>NetworkFetchProducer</h3><p>Fresco默认使用<code>HttpURLConnection</code>而不是Okhttp来请求网络图片，在生成ImagePipelineConfig时需要使用<code>OkHttpImagePipelineConfigFactory</code>来使用Okhttp来请求网络。</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="581px" preserveAspectRatio="none" style="width:1048px;height:581px;background:#FFFFFF;" version="1.1" viewBox="0 0 1048 581" width="1048px" zoomAndPan="magnify"><defs/><g><!--class Producer--><g id="elem_Producer"><rect codeLine="1" fill="#F1F1F1" height="48" id="Producer" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="191" x="213" y="10"/><ellipse cx="228" cy="26" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M228.9531,22.7813 L230.6719,22.7813 C231.0625,22.7813 231.25,22.75 231.375,22.6719 C231.6406,22.5156 231.7813,22.2344 231.7813,21.9375 C231.7813,21.6719 231.6719,21.4063 231.4375,21.2344 C231.2656,21.125 231.125,21.0938 230.6719,21.0938 L225.5313,21.0938 C225.0938,21.0938 224.9688,21.1094 224.8125,21.2031 C224.5625,21.3594 224.4063,21.6563 224.4063,21.9375 C224.4063,22.2188 224.5469,22.4688 224.7656,22.6406 C224.9219,22.75 225.1094,22.7813 225.5313,22.7813 L227.25,22.7813 L227.25,29.2969 L225.5313,29.2969 C225.0938,29.2969 224.9688,29.3125 224.8125,29.4219 C224.5625,29.5781 224.4063,29.8594 224.4063,30.1563 C224.4063,30.4063 224.5469,30.6719 224.7656,30.8281 C224.9219,30.9531 225.125,31 225.5313,31 L230.6719,31 C231.4219,31 231.7813,30.7188 231.7813,30.1563 C231.7813,29.875 231.6719,29.625 231.4375,29.4531 C231.2656,29.3281 231.125,29.2969 230.6719,29.2969 L228.9531,29.2969 L228.9531,22.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="64" x="242" y="30.8467">Producer</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="93" x="314" y="7"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="91" x="315" y="19.1387">EncodedImage</text><line style="stroke:#181818;stroke-width:0.5;" x1="214" x2="403" y1="42" y2="42"/><line style="stroke:#181818;stroke-width:0.5;" x1="214" x2="403" y1="50" y2="50"/></g><!--class NetworkFetchProducer--><g id="elem_NetworkFetchProducer"><rect fill="#F1F1F1" height="48" id="NetworkFetchProducer" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="198" x="209.5" y="119"/><ellipse cx="224.5" cy="135" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M226.8438,130.6719 C225.9063,130.2344 225.3125,130.0938 224.4375,130.0938 C221.8125,130.0938 219.8125,132.1719 219.8125,134.8906 L219.8125,136.0156 C219.8125,138.5938 221.9219,140.4844 224.8125,140.4844 C226.0313,140.4844 227.1875,140.1875 227.9375,139.6406 C228.5156,139.2344 228.8438,138.7813 228.8438,138.3906 C228.8438,137.9375 228.4531,137.5469 227.9844,137.5469 C227.7656,137.5469 227.5625,137.625 227.375,137.8125 C226.9219,138.2969 226.9219,138.2969 226.7344,138.3906 C226.3125,138.6563 225.625,138.7813 224.8594,138.7813 C222.8125,138.7813 221.5156,137.6875 221.5156,135.9844 L221.5156,134.8906 C221.5156,133.1094 222.7656,131.7969 224.5,131.7969 C225.0781,131.7969 225.6875,131.9531 226.1563,132.2031 C226.6406,132.4844 226.8125,132.7031 226.9063,133.1094 C226.9688,133.5156 227,133.6406 227.1406,133.7656 C227.2813,133.9063 227.5156,134.0156 227.7344,134.0156 C228,134.0156 228.2656,133.875 228.4375,133.6563 C228.5469,133.5 228.5781,133.3125 228.5781,132.8906 L228.5781,131.4688 C228.5781,131.0313 228.5625,130.9063 228.4688,130.75 C228.3125,130.4844 228.0313,130.3438 227.7344,130.3438 C227.4375,130.3438 227.2344,130.4375 227.0156,130.75 L226.8438,130.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="166" x="238.5" y="139.8467">NetworkFetchProducer</text><line style="stroke:#181818;stroke-width:0.5;" x1="210.5" x2="406.5" y1="151" y2="151"/><line style="stroke:#181818;stroke-width:0.5;" x1="210.5" x2="406.5" y1="159" y2="159"/></g><!--class NetworkFetcher--><g id="elem_NetworkFetcher"><rect fill="#F1F1F1" height="48" id="NetworkFetcher" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="149" x="613" y="119"/><ellipse cx="628" cy="135" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M630.3438,130.6719 C629.4063,130.2344 628.8125,130.0938 627.9375,130.0938 C625.3125,130.0938 623.3125,132.1719 623.3125,134.8906 L623.3125,136.0156 C623.3125,138.5938 625.4219,140.4844 628.3125,140.4844 C629.5313,140.4844 630.6875,140.1875 631.4375,139.6406 C632.0156,139.2344 632.3438,138.7813 632.3438,138.3906 C632.3438,137.9375 631.9531,137.5469 631.4844,137.5469 C631.2656,137.5469 631.0625,137.625 630.875,137.8125 C630.4219,138.2969 630.4219,138.2969 630.2344,138.3906 C629.8125,138.6563 629.125,138.7813 628.3594,138.7813 C626.3125,138.7813 625.0156,137.6875 625.0156,135.9844 L625.0156,134.8906 C625.0156,133.1094 626.2656,131.7969 628,131.7969 C628.5781,131.7969 629.1875,131.9531 629.6563,132.2031 C630.1406,132.4844 630.3125,132.7031 630.4063,133.1094 C630.4688,133.5156 630.5,133.6406 630.6406,133.7656 C630.7813,133.9063 631.0156,134.0156 631.2344,134.0156 C631.5,134.0156 631.7656,133.875 631.9375,133.6563 C632.0469,133.5 632.0781,133.3125 632.0781,132.8906 L632.0781,131.4688 C632.0781,131.0313 632.0625,130.9063 631.9688,130.75 C631.8125,130.4844 631.5313,130.3438 631.2344,130.3438 C630.9375,130.3438 630.7344,130.4375 630.5156,130.75 L630.3438,130.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="117" x="642" y="139.8467">NetworkFetcher</text><line style="stroke:#181818;stroke-width:0.5;" x1="614" x2="761" y1="151" y2="151"/><line style="stroke:#181818;stroke-width:0.5;" x1="614" x2="761" y1="159" y2="159"/></g><!--class MemoryChunkPool--><g id="elem_MemoryChunkPool"><rect codeLine="4" fill="#F1F1F1" height="48" id="MemoryChunkPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="165" x="431" y="526"/><ellipse cx="446" cy="542" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M448.0781,543.8125 L448.4688,544.7969 L448.0781,544.7969 C447.625,544.7969 447.5156,544.8125 447.3594,544.9219 C447.1094,545.0781 446.9531,545.3594 446.9531,545.6563 C446.9531,545.9219 447.0938,546.1719 447.3125,546.3281 C447.4531,546.4531 447.6563,546.5 448.0781,546.5 L450.4375,546.5 C450.7969,546.5 451.0156,546.4688 451.1563,546.375 C451.4063,546.2344 451.5625,545.9375 451.5625,545.6563 C451.5625,545.375 451.4219,545.125 451.2031,544.9688 C451.0313,544.8281 450.875,544.7969 450.4063,544.7969 L447.0156,536.5938 L443.3438,536.5938 C442.8906,536.5938 442.7656,536.6094 442.6094,536.7031 C442.3594,536.875 442.2031,537.1563 442.2031,537.4375 C442.2031,537.7188 442.3438,537.9688 442.5625,538.1406 C442.7344,538.25 442.9063,538.2813 443.3438,538.2813 L444.4219,538.2813 L441.7813,544.7969 C441.3594,544.7969 441.2031,544.8125 441.0469,544.9219 C440.7969,545.0781 440.6406,545.3594 440.6406,545.6563 C440.6406,546.2188 441.0156,546.5 441.7656,546.5 L444.0313,546.5 C444.3906,546.5 444.6094,546.4688 444.7344,546.375 C445,546.2344 445.1406,545.9375 445.1406,545.6563 C445.1406,545.375 445.0156,545.125 444.7969,544.9531 C444.625,544.8281 444.4844,544.7969 444.0313,544.7969 L443.6406,544.7969 L444.0313,543.8125 L448.0781,543.8125 Z M447.375,542.1094 L444.7031,542.1094 L446.0469,538.8438 L447.375,542.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="133" x="460" y="546.8467">MemoryChunkPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="432" x2="595" y1="558" y2="558"/><line style="stroke:#181818;stroke-width:0.5;" x1="432" x2="595" y1="566" y2="566"/></g><!--class ByteArrayPool--><g id="elem_ByteArrayPool"><rect fill="#F1F1F1" height="48" id="ByteArrayPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="135" x="443" y="119"/><ellipse cx="458" cy="135" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M460.3438,130.6719 C459.4063,130.2344 458.8125,130.0938 457.9375,130.0938 C455.3125,130.0938 453.3125,132.1719 453.3125,134.8906 L453.3125,136.0156 C453.3125,138.5938 455.4219,140.4844 458.3125,140.4844 C459.5313,140.4844 460.6875,140.1875 461.4375,139.6406 C462.0156,139.2344 462.3438,138.7813 462.3438,138.3906 C462.3438,137.9375 461.9531,137.5469 461.4844,137.5469 C461.2656,137.5469 461.0625,137.625 460.875,137.8125 C460.4219,138.2969 460.4219,138.2969 460.2344,138.3906 C459.8125,138.6563 459.125,138.7813 458.3594,138.7813 C456.3125,138.7813 455.0156,137.6875 455.0156,135.9844 L455.0156,134.8906 C455.0156,133.1094 456.2656,131.7969 458,131.7969 C458.5781,131.7969 459.1875,131.9531 459.6563,132.2031 C460.1406,132.4844 460.3125,132.7031 460.4063,133.1094 C460.4688,133.5156 460.5,133.6406 460.6406,133.7656 C460.7813,133.9063 461.0156,134.0156 461.2344,134.0156 C461.5,134.0156 461.7656,133.875 461.9375,133.6563 C462.0469,133.5 462.0781,133.3125 462.0781,132.8906 L462.0781,131.4688 C462.0781,131.0313 462.0625,130.9063 461.9688,130.75 C461.8125,130.4844 461.5313,130.3438 461.2344,130.3438 C460.9375,130.3438 460.7344,130.4375 460.5156,130.75 L460.3438,130.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="103" x="472" y="139.8467">ByteArrayPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="444" x2="577" y1="151" y2="151"/><line style="stroke:#181818;stroke-width:0.5;" x1="444" x2="577" y1="159" y2="159"/></g><!--class BaseNetworkFetcher--><g id="elem_BaseNetworkFetcher"><rect codeLine="6" fill="#F1F1F1" height="48" id="BaseNetworkFetcher" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="179" x="598" y="240"/><ellipse cx="613" cy="256" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M615.0781,257.8125 L615.4688,258.7969 L615.0781,258.7969 C614.625,258.7969 614.5156,258.8125 614.3594,258.9219 C614.1094,259.0781 613.9531,259.3594 613.9531,259.6563 C613.9531,259.9219 614.0938,260.1719 614.3125,260.3281 C614.4531,260.4531 614.6563,260.5 615.0781,260.5 L617.4375,260.5 C617.7969,260.5 618.0156,260.4688 618.1563,260.375 C618.4063,260.2344 618.5625,259.9375 618.5625,259.6563 C618.5625,259.375 618.4219,259.125 618.2031,258.9688 C618.0313,258.8281 617.875,258.7969 617.4063,258.7969 L614.0156,250.5938 L610.3438,250.5938 C609.8906,250.5938 609.7656,250.6094 609.6094,250.7031 C609.3594,250.875 609.2031,251.1563 609.2031,251.4375 C609.2031,251.7188 609.3438,251.9688 609.5625,252.1406 C609.7344,252.25 609.9063,252.2813 610.3438,252.2813 L611.4219,252.2813 L608.7813,258.7969 C608.3594,258.7969 608.2031,258.8125 608.0469,258.9219 C607.7969,259.0781 607.6406,259.3594 607.6406,259.6563 C607.6406,260.2188 608.0156,260.5 608.7656,260.5 L611.0313,260.5 C611.3906,260.5 611.6094,260.4688 611.7344,260.375 C612,260.2344 612.1406,259.9375 612.1406,259.6563 C612.1406,259.375 612.0156,259.125 611.7969,258.9531 C611.625,258.8281 611.4844,258.7969 611.0313,258.7969 L610.6406,258.7969 L611.0313,257.8125 L615.0781,257.8125 Z M614.375,256.1094 L611.7031,256.1094 L613.0469,252.8438 L614.375,256.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="147" x="627" y="260.8467">BaseNetworkFetcher</text><line style="stroke:#181818;stroke-width:0.5;" x1="599" x2="776" y1="272" y2="272"/><line style="stroke:#181818;stroke-width:0.5;" x1="599" x2="776" y1="280" y2="280"/></g><!--class HttpUrlConnectionNetworkFetcher--><g id="elem_HttpUrlConnectionNetworkFetcher"><rect fill="#F1F1F1" height="48" id="HttpUrlConnectionNetworkFetcher" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="285" x="518" y="389"/><ellipse cx="533" cy="405" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M535.3438,400.6719 C534.4063,400.2344 533.8125,400.0938 532.9375,400.0938 C530.3125,400.0938 528.3125,402.1719 528.3125,404.8906 L528.3125,406.0156 C528.3125,408.5938 530.4219,410.4844 533.3125,410.4844 C534.5313,410.4844 535.6875,410.1875 536.4375,409.6406 C537.0156,409.2344 537.3438,408.7813 537.3438,408.3906 C537.3438,407.9375 536.9531,407.5469 536.4844,407.5469 C536.2656,407.5469 536.0625,407.625 535.875,407.8125 C535.4219,408.2969 535.4219,408.2969 535.2344,408.3906 C534.8125,408.6563 534.125,408.7813 533.3594,408.7813 C531.3125,408.7813 530.0156,407.6875 530.0156,405.9844 L530.0156,404.8906 C530.0156,403.1094 531.2656,401.7969 533,401.7969 C533.5781,401.7969 534.1875,401.9531 534.6563,402.2031 C535.1406,402.4844 535.3125,402.7031 535.4063,403.1094 C535.4688,403.5156 535.5,403.6406 535.6406,403.7656 C535.7813,403.9063 536.0156,404.0156 536.2344,404.0156 C536.5,404.0156 536.7656,403.875 536.9375,403.6563 C537.0469,403.5 537.0781,403.3125 537.0781,402.8906 L537.0781,401.4688 C537.0781,401.0313 537.0625,400.9063 536.9688,400.75 C536.8125,400.4844 536.5313,400.3438 536.2344,400.3438 C535.9375,400.3438 535.7344,400.4375 535.5156,400.75 L535.3438,400.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="253" x="547" y="409.8467">HttpUrlConnectionNetworkFetcher</text><line style="stroke:#181818;stroke-width:0.5;" x1="519" x2="802" y1="421" y2="421"/><line style="stroke:#181818;stroke-width:0.5;" x1="519" x2="802" y1="429" y2="429"/></g><!--class OkHttpNetworkFetcher--><g id="elem_OkHttpNetworkFetcher"><rect fill="#F1F1F1" height="48" id="OkHttpNetworkFetcher" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="203" x="838" y="389"/><ellipse cx="853" cy="405" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M855.3438,400.6719 C854.4063,400.2344 853.8125,400.0938 852.9375,400.0938 C850.3125,400.0938 848.3125,402.1719 848.3125,404.8906 L848.3125,406.0156 C848.3125,408.5938 850.4219,410.4844 853.3125,410.4844 C854.5313,410.4844 855.6875,410.1875 856.4375,409.6406 C857.0156,409.2344 857.3438,408.7813 857.3438,408.3906 C857.3438,407.9375 856.9531,407.5469 856.4844,407.5469 C856.2656,407.5469 856.0625,407.625 855.875,407.8125 C855.4219,408.2969 855.4219,408.2969 855.2344,408.3906 C854.8125,408.6563 854.125,408.7813 853.3594,408.7813 C851.3125,408.7813 850.0156,407.6875 850.0156,405.9844 L850.0156,404.8906 C850.0156,403.1094 851.2656,401.7969 853,401.7969 C853.5781,401.7969 854.1875,401.9531 854.6563,402.2031 C855.1406,402.4844 855.3125,402.7031 855.4063,403.1094 C855.4688,403.5156 855.5,403.6406 855.6406,403.7656 C855.7813,403.9063 856.0156,404.0156 856.2344,404.0156 C856.5,404.0156 856.7656,403.875 856.9375,403.6563 C857.0469,403.5 857.0781,403.3125 857.0781,402.8906 L857.0781,401.4688 C857.0781,401.0313 857.0625,400.9063 856.9688,400.75 C856.8125,400.4844 856.5313,400.3438 856.2344,400.3438 C855.9375,400.3438 855.7344,400.4375 855.5156,400.75 L855.3438,400.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="171" x="867" y="409.8467">OkHttpNetworkFetcher</text><line style="stroke:#181818;stroke-width:0.5;" x1="839" x2="1040" y1="421" y2="421"/><line style="stroke:#181818;stroke-width:0.5;" x1="839" x2="1040" y1="429" y2="429"/></g><!--class MemoryPooledByteBufferFactory--><g id="elem_MemoryPooledByteBufferFactory"><rect codeLine="15" fill="#F1F1F1" height="64.2969" id="MemoryPooledByteBufferFactory" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="272" x="21.5" y="232"/><ellipse cx="36.5" cy="248" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M38.8438,243.6719 C37.9063,243.2344 37.3125,243.0938 36.4375,243.0938 C33.8125,243.0938 31.8125,245.1719 31.8125,247.8906 L31.8125,249.0156 C31.8125,251.5938 33.9219,253.4844 36.8125,253.4844 C38.0313,253.4844 39.1875,253.1875 39.9375,252.6406 C40.5156,252.2344 40.8438,251.7813 40.8438,251.3906 C40.8438,250.9375 40.4531,250.5469 39.9844,250.5469 C39.7656,250.5469 39.5625,250.625 39.375,250.8125 C38.9219,251.2969 38.9219,251.2969 38.7344,251.3906 C38.3125,251.6563 37.625,251.7813 36.8594,251.7813 C34.8125,251.7813 33.5156,250.6875 33.5156,248.9844 L33.5156,247.8906 C33.5156,246.1094 34.7656,244.7969 36.5,244.7969 C37.0781,244.7969 37.6875,244.9531 38.1563,245.2031 C38.6406,245.4844 38.8125,245.7031 38.9063,246.1094 C38.9688,246.5156 39,246.6406 39.1406,246.7656 C39.2813,246.9063 39.5156,247.0156 39.7344,247.0156 C40,247.0156 40.2656,246.875 40.4375,246.6563 C40.5469,246.5 40.5781,246.3125 40.5781,245.8906 L40.5781,244.4688 C40.5781,244.0313 40.5625,243.9063 40.4688,243.75 C40.3125,243.4844 40.0313,243.3438 39.7344,243.3438 C39.4375,243.3438 39.2344,243.4375 39.0156,243.75 L38.8438,243.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="240" x="50.5" y="252.8467">MemoryPooledByteBufferFactory</text><line style="stroke:#181818;stroke-width:0.5;" x1="22.5" x2="292.5" y1="264" y2="264"/><line style="stroke:#181818;stroke-width:0.5;" x1="22.5" x2="292.5" y1="272" y2="272"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="143" x="27.5" y="288.9951">newOutputStream()</text></g><!--class MemoryPooledByteBufferOutputStream--><g id="elem_MemoryPooledByteBufferOutputStream"><rect codeLine="11" fill="#F1F1F1" height="64.2969" id="MemoryPooledByteBufferOutputStream" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="322" x="125.5" y="381"/><ellipse cx="140.5" cy="397" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M142.8438,392.6719 C141.9063,392.2344 141.3125,392.0938 140.4375,392.0938 C137.8125,392.0938 135.8125,394.1719 135.8125,396.8906 L135.8125,398.0156 C135.8125,400.5938 137.9219,402.4844 140.8125,402.4844 C142.0313,402.4844 143.1875,402.1875 143.9375,401.6406 C144.5156,401.2344 144.8438,400.7813 144.8438,400.3906 C144.8438,399.9375 144.4531,399.5469 143.9844,399.5469 C143.7656,399.5469 143.5625,399.625 143.375,399.8125 C142.9219,400.2969 142.9219,400.2969 142.7344,400.3906 C142.3125,400.6563 141.625,400.7813 140.8594,400.7813 C138.8125,400.7813 137.5156,399.6875 137.5156,397.9844 L137.5156,396.8906 C137.5156,395.1094 138.7656,393.7969 140.5,393.7969 C141.0781,393.7969 141.6875,393.9531 142.1563,394.2031 C142.6406,394.4844 142.8125,394.7031 142.9063,395.1094 C142.9688,395.5156 143,395.6406 143.1406,395.7656 C143.2813,395.9063 143.5156,396.0156 143.7344,396.0156 C144,396.0156 144.2656,395.875 144.4375,395.6563 C144.5469,395.5 144.5781,395.3125 144.5781,394.8906 L144.5781,393.4688 C144.5781,393.0313 144.5625,392.9063 144.4688,392.75 C144.3125,392.4844 144.0313,392.3438 143.7344,392.3438 C143.4375,392.3438 143.2344,392.4375 143.0156,392.75 L142.8438,392.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="290" x="154.5" y="401.8467">MemoryPooledByteBufferOutputStream</text><line style="stroke:#181818;stroke-width:0.5;" x1="126.5" x2="446.5" y1="413" y2="413"/><line style="stroke:#181818;stroke-width:0.5;" x1="126.5" x2="446.5" y1="421" y2="421"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="295" x="131.5" y="437.9951">MemoryPooledByteBuffer toByteBuffer()</text></g><!--class MemoryPooledByteBuffer--><g id="elem_MemoryPooledByteBuffer"><rect fill="#F1F1F1" height="48" id="MemoryPooledByteBuffer" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="218" x="177.5" y="526"/><ellipse cx="192.5" cy="542" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M194.8438,537.6719 C193.9063,537.2344 193.3125,537.0938 192.4375,537.0938 C189.8125,537.0938 187.8125,539.1719 187.8125,541.8906 L187.8125,543.0156 C187.8125,545.5938 189.9219,547.4844 192.8125,547.4844 C194.0313,547.4844 195.1875,547.1875 195.9375,546.6406 C196.5156,546.2344 196.8438,545.7813 196.8438,545.3906 C196.8438,544.9375 196.4531,544.5469 195.9844,544.5469 C195.7656,544.5469 195.5625,544.625 195.375,544.8125 C194.9219,545.2969 194.9219,545.2969 194.7344,545.3906 C194.3125,545.6563 193.625,545.7813 192.8594,545.7813 C190.8125,545.7813 189.5156,544.6875 189.5156,542.9844 L189.5156,541.8906 C189.5156,540.1094 190.7656,538.7969 192.5,538.7969 C193.0781,538.7969 193.6875,538.9531 194.1563,539.2031 C194.6406,539.4844 194.8125,539.7031 194.9063,540.1094 C194.9688,540.5156 195,540.6406 195.1406,540.7656 C195.2813,540.9063 195.5156,541.0156 195.7344,541.0156 C196,541.0156 196.2656,540.875 196.4375,540.6563 C196.5469,540.5 196.5781,540.3125 196.5781,539.8906 L196.5781,538.4688 C196.5781,538.0313 196.5625,537.9063 196.4688,537.75 C196.3125,537.4844 196.0313,537.3438 195.7344,537.3438 C195.4375,537.3438 195.2344,537.4375 195.0156,537.75 L194.8438,537.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="186" x="206.5" y="546.8467">MemoryPooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="178.5" x2="394.5" y1="558" y2="558"/><line style="stroke:#181818;stroke-width:0.5;" x1="178.5" x2="394.5" y1="566" y2="566"/></g><!--class MemoryChunk--><g id="elem_MemoryChunk"><rect fill="#F1F1F1" height="48" id="MemoryChunk" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="135" x="7" y="526"/><ellipse cx="22" cy="542" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M24.3438,537.6719 C23.4063,537.2344 22.8125,537.0938 21.9375,537.0938 C19.3125,537.0938 17.3125,539.1719 17.3125,541.8906 L17.3125,543.0156 C17.3125,545.5938 19.4219,547.4844 22.3125,547.4844 C23.5313,547.4844 24.6875,547.1875 25.4375,546.6406 C26.0156,546.2344 26.3438,545.7813 26.3438,545.3906 C26.3438,544.9375 25.9531,544.5469 25.4844,544.5469 C25.2656,544.5469 25.0625,544.625 24.875,544.8125 C24.4219,545.2969 24.4219,545.2969 24.2344,545.3906 C23.8125,545.6563 23.125,545.7813 22.3594,545.7813 C20.3125,545.7813 19.0156,544.6875 19.0156,542.9844 L19.0156,541.8906 C19.0156,540.1094 20.2656,538.7969 22,538.7969 C22.5781,538.7969 23.1875,538.9531 23.6563,539.2031 C24.1406,539.4844 24.3125,539.7031 24.4063,540.1094 C24.4688,540.5156 24.5,540.6406 24.6406,540.7656 C24.7813,540.9063 25.0156,541.0156 25.2344,541.0156 C25.5,541.0156 25.7656,540.875 25.9375,540.6563 C26.0469,540.5 26.0781,540.3125 26.0781,539.8906 L26.0781,538.4688 C26.0781,538.0313 26.0625,537.9063 25.9688,537.75 C25.8125,537.4844 25.5313,537.3438 25.2344,537.3438 C24.9375,537.3438 24.7344,537.4375 24.5156,537.75 L24.3438,537.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="103" x="36" y="546.8467">MemoryChunk</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="141" y1="558" y2="558"/><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="141" y1="566" y2="566"/></g><!--reverse link Producer to NetworkFetchProducer--><g id="link_Producer_NetworkFetchProducer"><path codeLine="2" d="M308.5,76.217 C308.5,94.165 308.5,100.892 308.5,118.828 " fill="none" id="Producer-backto-NetworkFetchProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="308.5,58.217,302.5,76.217,314.5,76.217,308.5,58.217" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link NetworkFetchProducer to NetworkFetcher--><g id="link_NetworkFetchProducer_NetworkFetcher"><path codeLine="3" d="M365.9464,113.911 C391.2334,102.197 412.583,94.429 443,88.5 C501.892,77.022 519.592,74.768 578,88.5 C603.426,94.478 629.697,107.293 650.132,118.994 " fill="none" id="NetworkFetchProducer-backto-NetworkFetcher" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="355.058,118.955,362.1836,120.0625,365.9464,113.911,358.8209,112.8035,355.058,118.955" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link NetworkFetchProducer to ByteArrayPool--><g id="link_NetworkFetchProducer_ByteArrayPool"><path codeLine="5" d="M419.527,143 C431.326,143 431.125,143 442.924,143 " fill="none" id="NetworkFetchProducer-backto-ByteArrayPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="407.527,143,413.527,147,419.527,143,413.527,139,407.527,143" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BaseNetworkFetcher to HttpUrlConnectionNetworkFetcher--><g id="link_BaseNetworkFetcher_HttpUrlConnectionNetworkFetcher"><path codeLine="7" d="M679.97,305.9968 C674.914,333.5218 669.805,361.339 664.758,388.816 " fill="none" id="BaseNetworkFetcher-backto-HttpUrlConnectionNetworkFetcher" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="683.222,288.293,674.0688,304.9128,685.8713,307.0808,683.222,288.293" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link NetworkFetcher to BaseNetworkFetcher--><g id="link_NetworkFetcher_BaseNetworkFetcher"><path codeLine="8" d="M687.5,185.227 C687.5,206.195 687.5,218.882 687.5,239.832 " fill="none" id="NetworkFetcher-backto-BaseNetworkFetcher" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="687.5,167.227,681.5,185.227,693.5,185.227,687.5,167.227" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BaseNetworkFetcher to OkHttpNetworkFetcher--><g id="link_BaseNetworkFetcher_OkHttpNetworkFetcher"><path codeLine="9" d="M742.7,297.1997 C789.827,324.6907 852.456,361.224 899.663,388.762 " fill="none" id="BaseNetworkFetcher-backto-OkHttpNetworkFetcher" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="727.152,288.13,739.6767,302.3824,745.7232,292.0171,727.152,288.13" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link NetworkFetchProducer to MemoryPooledByteBufferFactory--><g id="link_NetworkFetchProducer_MemoryPooledByteBufferFactory"><path codeLine="10" d="M269.602,174.6547 C247.716,191.9027 226.911,208.299 202.077,227.87 " fill="none" id="NetworkFetchProducer-backto-MemoryPooledByteBufferFactory" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="279.027,167.227,271.8386,167.7992,269.602,174.6547,276.7904,174.0825,279.027,167.227" style="stroke:#181818;stroke-width:1.0;"/></g><!--link MemoryPooledByteBufferOutputStream to MemoryPooledByteBuffer--><g id="link_MemoryPooledByteBufferOutputStream_MemoryPooledByteBuffer"><path codeLine="14" d="M448.5,433 C511.716,433 407.4903,489.4384 339.5973,523.2675 " fill="none" id="MemoryPooledByteBufferOutputStream-to-MemoryPooledByteBuffer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="334.227,525.9434,344.0663,525.5098,338.7022,523.7135,340.4985,518.3494,334.227,525.9434" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="39" x="420.5" y="492.0669">return</text></g><!--link MemoryPooledByteBufferFactory to MemoryPooledByteBufferOutputStream--><g id="link_MemoryPooledByteBufferFactory_MemoryPooledByteBufferOutputStream"><path codeLine="18" d="M294.5,284 C313.147,284 305.2925,332.945 296.7175,370.833 " fill="none" id="MemoryPooledByteBufferFactory-to-MemoryPooledByteBufferOutputStream" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="295.393,376.685,301.281,368.79,296.4967,371.8083,293.4783,367.024,295.393,376.685" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="39" x="305.5" y="343.0669">return</text></g><!--link NetworkFetchProducer to MemoryPooledByteBufferOutputStream--><g id="link_NetworkFetchProducer_MemoryPooledByteBufferOutputStream"><path codeLine="19" d="M321.492,167.02 C341.41,205.515 374.676,284.85 349.5,347 C345.075,357.924 341.8719,363.5882 333.8469,372.4122 " fill="none" id="NetworkFetchProducer-to-MemoryPooledByteBufferOutputStream" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:7.0,7.0;"/><polygon fill="#181818" points="329.81,376.851,338.8246,372.884,333.1741,373.152,332.9061,367.5015,329.81,376.851" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="91" x="360.5" y="268.5669">toByteBuffer()</text></g><!--reverse link MemoryPooledByteBufferOutputStream to MemoryChunkPool--><g id="link_MemoryPooledByteBufferOutputStream_MemoryChunkPool"><path codeLine="20" d="M429.2386,454.1437 C447.1316,462.2237 453.524,467.105 468.5,479 C484.112,491.4002 495.969,510.7726 503.582,525.997 " fill="none" id="MemoryPooledByteBufferOutputStream-backto-MemoryChunkPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="418.302,449.205,422.1241,455.3199,429.2386,454.1437,425.4165,448.0288,418.302,449.205" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link MemoryPooledByteBufferOutputStream to MemoryChunk--><g id="link_MemoryPooledByteBufferOutputStream_MemoryChunk"><path codeLine="21" d="M221.2311,455.5627 C183.1991,479.7817 143.842,504.8436 110.72,525.9353 " fill="none" id="MemoryPooledByteBufferOutputStream-backto-MemoryChunk" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="231.353,449.117,224.1435,448.9659,221.2311,455.5627,228.4406,455.7138,231.353,449.117" style="stroke:#181818;stroke-width:1.0;"/></g><!--link MemoryChunk to MemoryPooledByteBuffer--><g id="link_MemoryChunk_MemoryPooledByteBuffer"><path codeLine="23" d="M142.406,550 C154.039,550 153.671,550 165.304,550 " fill="none" id="MemoryChunk-to-MemoryPooledByteBuffer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="177.304,550,171.304,546,165.304,550,171.304,554,177.304,550" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[bPDDReCm48Ntd69s_P6S0w08gKIDsaMRI5KFu9eX8C16mrWHQdhtcee2eK0Jxp3lVNxFFwbcf5WgX3sPo2gazQDM9iBekP073BnNvAEXR8kiaby925kAKz1PfaNtWj93mWA6VvrOVbHCKZ6yO66etYHMPtjZyZaAX3NZ0v6iVrITFPGLZj1_fs1z4WAUcCjtoZT6QrIS6ZtoJNckmE-oPe45vg2DQ6itNJ1ggeKsZf6shfARzbGkgsf6ixDSMdvZGbd0fmTkJ0k1JVznU-TzUVy3VNze0Y62ERWFX6n9BsPj-xGnDHw7Qor4Qds-Fx8i13gJTU4czt-rkX0osi0BFFtHzZVwUfjt0zClphKVSsRm3fbZp6VORm00]--></g></svg>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//NetworkFetchProducer.java</span></span><br><span class="line">  <span class="keyword">protected</span> <span class="keyword">void</span> <span class="title function_">onResponse</span><span class="params">(</span></span><br><span class="line"><span class="params">      FetchState fetchState, InputStream responseData, <span class="type">int</span> responseContentLength)</span></span><br><span class="line">      <span class="keyword">throws</span> IOException &#123;</span><br><span class="line">    <span class="keyword">final</span> PooledByteBufferOutputStream pooledOutputStream;</span><br><span class="line">    <span class="keyword">if</span> (responseContentLength &gt; <span class="number">0</span>) &#123;</span><br><span class="line">      pooledOutputStream = mPooledByteBufferFactory.newOutputStream(responseContentLength);</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">      pooledOutputStream = mPooledByteBufferFactory.newOutputStream();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">final</span> <span class="type">byte</span>[] ioArray = mByteArrayPool.get(READ_SIZE);</span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">      <span class="type">int</span> length;</span><br><span class="line">      <span class="comment">//responseData（InputStream）对应okhttp3.ResponseBody#byteStream，原始图片byte数据流</span></span><br><span class="line">      <span class="comment">//循环从InputStream中读取数据到ioArray中</span></span><br><span class="line">      <span class="keyword">while</span> ((length = responseData.read(ioArray)) &gt;= <span class="number">0</span>) &#123;</span><br><span class="line">        <span class="keyword">if</span> (length &gt; <span class="number">0</span>) &#123;</span><br><span class="line">          <span class="comment">//将图片数据写入到pooledOutputStream是MemoryPooledByteBufferOutputStream类型</span></span><br><span class="line">          pooledOutputStream.write(ioArray, <span class="number">0</span>, length);</span><br><span class="line">          maybeHandleIntermediateResult(pooledOutputStream, fetchState);</span><br><span class="line">          <span class="type">float</span> <span class="variable">progress</span> <span class="operator">=</span> calculateProgress(pooledOutputStream.size(), responseContentLength);</span><br><span class="line">          fetchState.getConsumer().onProgressUpdate(progress);</span><br><span class="line">        &#125;</span><br><span class="line">      &#125;</span><br><span class="line">      mNetworkFetcher.onFetchCompletion(fetchState, pooledOutputStream.size());</span><br><span class="line">      handleFinalResult(pooledOutputStream, fetchState);</span><br><span class="line">    &#125; <span class="keyword">finally</span> &#123;</span><br><span class="line">      mByteArrayPool.release(ioArray);</span><br><span class="line">      pooledOutputStream.close();</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<p>NetworkFetchProducer从网络请求的图片数据写入到<code>MemoryPooledByteBufferOutputStream</code>中。<code>MemoryPooledByteBufferOutputStream</code>从内存池中申请内存块（详情参考<a href="#%E5%86%85%E5%AD%98%E5%9D%97%E7%BC%93%E5%AD%98%E6%B1%A0-memorychunkpool">内存块缓存池</a>一节），在OutputStream的close中会把申请的内存块放回到内存池中。</p>
<p>NetworkFetchProducer处理结束时返回一个<code>EncodedImage</code>类型数据，class结构如下，图片数据保存在MemoryChunk中。</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="758px" preserveAspectRatio="none" style="width:777px;height:758px;background:#FFFFFF;" version="1.1" viewBox="0 0 777 758" width="777px" zoomAndPan="magnify"><defs/><g><!--class PooledByteBuffer--><g id="elem_PooledByteBuffer"><rect codeLine="1" fill="#F1F1F1" height="48" id="PooledByteBuffer" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="156" x="309" y="347"/><ellipse cx="324" cy="363" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M324.9531,359.7813 L326.6719,359.7813 C327.0625,359.7813 327.25,359.75 327.375,359.6719 C327.6406,359.5156 327.7813,359.2344 327.7813,358.9375 C327.7813,358.6719 327.6719,358.4063 327.4375,358.2344 C327.2656,358.125 327.125,358.0938 326.6719,358.0938 L321.5313,358.0938 C321.0938,358.0938 320.9688,358.1094 320.8125,358.2031 C320.5625,358.3594 320.4063,358.6563 320.4063,358.9375 C320.4063,359.2188 320.5469,359.4688 320.7656,359.6406 C320.9219,359.75 321.1094,359.7813 321.5313,359.7813 L323.25,359.7813 L323.25,366.2969 L321.5313,366.2969 C321.0938,366.2969 320.9688,366.3125 320.8125,366.4219 C320.5625,366.5781 320.4063,366.8594 320.4063,367.1563 C320.4063,367.4063 320.5469,367.6719 320.7656,367.8281 C320.9219,367.9531 321.125,368 321.5313,368 L326.6719,368 C327.4219,368 327.7813,367.7188 327.7813,367.1563 C327.7813,366.875 327.6719,366.625 327.4375,366.4531 C327.2656,366.3281 327.125,366.2969 326.6719,366.2969 L324.9531,366.2969 L324.9531,359.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="124" x="338" y="367.8467">PooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="310" x2="464" y1="379" y2="379"/><line style="stroke:#181818;stroke-width:0.5;" x1="310" x2="464" y1="387" y2="387"/></g><!--class CloseableReference--><g id="elem_CloseableReference"><rect codeLine="2" fill="#F1F1F1" height="48" id="CloseableReference" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="283" x="200.5" y="115"/><ellipse cx="215.5" cy="131" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M217.8438,126.6719 C216.9063,126.2344 216.3125,126.0938 215.4375,126.0938 C212.8125,126.0938 210.8125,128.1719 210.8125,130.8906 L210.8125,132.0156 C210.8125,134.5938 212.9219,136.4844 215.8125,136.4844 C217.0313,136.4844 218.1875,136.1875 218.9375,135.6406 C219.5156,135.2344 219.8438,134.7813 219.8438,134.3906 C219.8438,133.9375 219.4531,133.5469 218.9844,133.5469 C218.7656,133.5469 218.5625,133.625 218.375,133.8125 C217.9219,134.2969 217.9219,134.2969 217.7344,134.3906 C217.3125,134.6563 216.625,134.7813 215.8594,134.7813 C213.8125,134.7813 212.5156,133.6875 212.5156,131.9844 L212.5156,130.8906 C212.5156,129.1094 213.7656,127.7969 215.5,127.7969 C216.0781,127.7969 216.6875,127.9531 217.1563,128.2031 C217.6406,128.4844 217.8125,128.7031 217.9063,129.1094 C217.9688,129.5156 218,129.6406 218.1406,129.7656 C218.2813,129.9063 218.5156,130.0156 218.7344,130.0156 C219,130.0156 219.2656,129.875 219.4375,129.6563 C219.5469,129.5 219.5781,129.3125 219.5781,128.8906 L219.5781,127.4688 C219.5781,127.0313 219.5625,126.9063 219.4688,126.75 C219.3125,126.4844 219.0313,126.3438 218.7344,126.3438 C218.4375,126.3438 218.2344,126.4375 218.0156,126.75 L217.8438,126.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="145" x="229.5" y="135.8467">CloseableReference</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="104" x="382.5" y="112"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="102" x="383.5" y="124.1387">PooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="201.5" x2="482.5" y1="147" y2="147"/><line style="stroke:#181818;stroke-width:0.5;" x1="201.5" x2="482.5" y1="155" y2="155"/></g><!--class EncodedImage--><g id="elem_EncodedImage"><rect fill="#F1F1F1" height="48" id="EncodedImage" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="138" x="273" y="7"/><ellipse cx="288" cy="23" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M290.3438,18.6719 C289.4063,18.2344 288.8125,18.0938 287.9375,18.0938 C285.3125,18.0938 283.3125,20.1719 283.3125,22.8906 L283.3125,24.0156 C283.3125,26.5938 285.4219,28.4844 288.3125,28.4844 C289.5313,28.4844 290.6875,28.1875 291.4375,27.6406 C292.0156,27.2344 292.3438,26.7813 292.3438,26.3906 C292.3438,25.9375 291.9531,25.5469 291.4844,25.5469 C291.2656,25.5469 291.0625,25.625 290.875,25.8125 C290.4219,26.2969 290.4219,26.2969 290.2344,26.3906 C289.8125,26.6563 289.125,26.7813 288.3594,26.7813 C286.3125,26.7813 285.0156,25.6875 285.0156,23.9844 L285.0156,22.8906 C285.0156,21.1094 286.2656,19.7969 288,19.7969 C288.5781,19.7969 289.1875,19.9531 289.6563,20.2031 C290.1406,20.4844 290.3125,20.7031 290.4063,21.1094 C290.4688,21.5156 290.5,21.6406 290.6406,21.7656 C290.7813,21.9063 291.0156,22.0156 291.2344,22.0156 C291.5,22.0156 291.7656,21.875 291.9375,21.6563 C292.0469,21.5 292.0781,21.3125 292.0781,20.8906 L292.0781,19.4688 C292.0781,19.0313 292.0625,18.9063 291.9688,18.75 C291.8125,18.4844 291.5313,18.3438 291.2344,18.3438 C290.9375,18.3438 290.7344,18.4375 290.5156,18.75 L290.3438,18.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="106" x="302" y="27.8467">EncodedImage</text><line style="stroke:#181818;stroke-width:0.5;" x1="274" x2="410" y1="39" y2="39"/><line style="stroke:#181818;stroke-width:0.5;" x1="274" x2="410" y1="47" y2="47"/></g><!--class MemoryPooledByteBuffer--><g id="elem_MemoryPooledByteBuffer"><rect codeLine="4" fill="#F1F1F1" height="64.2969" id="MemoryPooledByteBuffer" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="218" x="181" y="455"/><ellipse cx="196" cy="471" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M198.3438,466.6719 C197.4063,466.2344 196.8125,466.0938 195.9375,466.0938 C193.3125,466.0938 191.3125,468.1719 191.3125,470.8906 L191.3125,472.0156 C191.3125,474.5938 193.4219,476.4844 196.3125,476.4844 C197.5313,476.4844 198.6875,476.1875 199.4375,475.6406 C200.0156,475.2344 200.3438,474.7813 200.3438,474.3906 C200.3438,473.9375 199.9531,473.5469 199.4844,473.5469 C199.2656,473.5469 199.0625,473.625 198.875,473.8125 C198.4219,474.2969 198.4219,474.2969 198.2344,474.3906 C197.8125,474.6563 197.125,474.7813 196.3594,474.7813 C194.3125,474.7813 193.0156,473.6875 193.0156,471.9844 L193.0156,470.8906 C193.0156,469.1094 194.2656,467.7969 196,467.7969 C196.5781,467.7969 197.1875,467.9531 197.6563,468.2031 C198.1406,468.4844 198.3125,468.7031 198.4063,469.1094 C198.4688,469.5156 198.5,469.6406 198.6406,469.7656 C198.7813,469.9063 199.0156,470.0156 199.2344,470.0156 C199.5,470.0156 199.7656,469.875 199.9375,469.6563 C200.0469,469.5 200.0781,469.3125 200.0781,468.8906 L200.0781,467.4688 C200.0781,467.0313 200.0625,466.9063 199.9688,466.75 C199.8125,466.4844 199.5313,466.3438 199.2344,466.3438 C198.9375,466.3438 198.7344,466.4375 198.5156,466.75 L198.3438,466.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="186" x="210" y="475.8467">MemoryPooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="182" x2="398" y1="487" y2="487"/><line style="stroke:#181818;stroke-width:0.5;" x1="182" x2="398" y1="495" y2="495"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="47" x="187" y="511.9951">close()</text></g><!--class DefaultCloseableReference--><g id="elem_DefaultCloseableReference"><rect codeLine="8" fill="#F1F1F1" height="48" id="DefaultCloseableReference" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="336" x="7" y="231"/><ellipse cx="22" cy="247" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M24.3438,242.6719 C23.4063,242.2344 22.8125,242.0938 21.9375,242.0938 C19.3125,242.0938 17.3125,244.1719 17.3125,246.8906 L17.3125,248.0156 C17.3125,250.5938 19.4219,252.4844 22.3125,252.4844 C23.5313,252.4844 24.6875,252.1875 25.4375,251.6406 C26.0156,251.2344 26.3438,250.7813 26.3438,250.3906 C26.3438,249.9375 25.9531,249.5469 25.4844,249.5469 C25.2656,249.5469 25.0625,249.625 24.875,249.8125 C24.4219,250.2969 24.4219,250.2969 24.2344,250.3906 C23.8125,250.6563 23.125,250.7813 22.3594,250.7813 C20.3125,250.7813 19.0156,249.6875 19.0156,247.9844 L19.0156,246.8906 C19.0156,245.1094 20.2656,243.7969 22,243.7969 C22.5781,243.7969 23.1875,243.9531 23.6563,244.2031 C24.1406,244.4844 24.3125,244.7031 24.4063,245.1094 C24.4688,245.5156 24.5,245.6406 24.6406,245.7656 C24.7813,245.9063 25.0156,246.0156 25.2344,246.0156 C25.5,246.0156 25.7656,245.875 25.9375,245.6563 C26.0469,245.5 26.0781,245.3125 26.0781,244.8906 L26.0781,243.4688 C26.0781,243.0313 26.0625,242.9063 25.9688,242.75 C25.8125,242.4844 25.5313,242.3438 25.2344,242.3438 C24.9375,242.3438 24.7344,242.4375 24.5156,242.75 L24.3438,242.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="198" x="36" y="251.8467">DefaultCloseableReference</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="104" x="242" y="228"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="102" x="243" y="240.1387">PooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="342" y1="263" y2="263"/><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="342" y1="271" y2="271"/></g><!--class SharedReference--><g id="elem_SharedReference"><rect codeLine="10" fill="#F1F1F1" height="64.2969" id="SharedReference" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="263" x="378.5" y="223"/><ellipse cx="393.5" cy="239" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M395.8438,234.6719 C394.9063,234.2344 394.3125,234.0938 393.4375,234.0938 C390.8125,234.0938 388.8125,236.1719 388.8125,238.8906 L388.8125,240.0156 C388.8125,242.5938 390.9219,244.4844 393.8125,244.4844 C395.0313,244.4844 396.1875,244.1875 396.9375,243.6406 C397.5156,243.2344 397.8438,242.7813 397.8438,242.3906 C397.8438,241.9375 397.4531,241.5469 396.9844,241.5469 C396.7656,241.5469 396.5625,241.625 396.375,241.8125 C395.9219,242.2969 395.9219,242.2969 395.7344,242.3906 C395.3125,242.6563 394.625,242.7813 393.8594,242.7813 C391.8125,242.7813 390.5156,241.6875 390.5156,239.9844 L390.5156,238.8906 C390.5156,237.1094 391.7656,235.7969 393.5,235.7969 C394.0781,235.7969 394.6875,235.9531 395.1563,236.2031 C395.6406,236.4844 395.8125,236.7031 395.9063,237.1094 C395.9688,237.5156 396,237.6406 396.1406,237.7656 C396.2813,237.9063 396.5156,238.0156 396.7344,238.0156 C397,238.0156 397.2656,237.875 397.4375,237.6563 C397.5469,237.5 397.5781,237.3125 397.5781,236.8906 L397.5781,235.4688 C397.5781,235.0313 397.5625,234.9063 397.4688,234.75 C397.3125,234.4844 397.0313,234.3438 396.7344,234.3438 C396.4375,234.3438 396.2344,234.4375 396.0156,234.75 L395.8438,234.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="125" x="407.5" y="243.8467">SharedReference</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="104" x="540.5" y="220"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="102" x="541.5" y="232.1387">PooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="379.5" x2="640.5" y1="255" y2="255"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="106" x="384.5" y="271.9951">int mRefCount</text><line style="stroke:#181818;stroke-width:0.5;" x1="379.5" x2="640.5" y1="279.2969" y2="279.2969"/></g><!--class ResourceReleaser--><g id="elem_ResourceReleaser"><rect codeLine="15" fill="#F1F1F1" height="48" id="ResourceReleaser" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="266" x="500" y="347"/><ellipse cx="515" cy="363" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M517.3438,358.6719 C516.4063,358.2344 515.8125,358.0938 514.9375,358.0938 C512.3125,358.0938 510.3125,360.1719 510.3125,362.8906 L510.3125,364.0156 C510.3125,366.5938 512.4219,368.4844 515.3125,368.4844 C516.5313,368.4844 517.6875,368.1875 518.4375,367.6406 C519.0156,367.2344 519.3438,366.7813 519.3438,366.3906 C519.3438,365.9375 518.9531,365.5469 518.4844,365.5469 C518.2656,365.5469 518.0625,365.625 517.875,365.8125 C517.4219,366.2969 517.4219,366.2969 517.2344,366.3906 C516.8125,366.6563 516.125,366.7813 515.3594,366.7813 C513.3125,366.7813 512.0156,365.6875 512.0156,363.9844 L512.0156,362.8906 C512.0156,361.1094 513.2656,359.7969 515,359.7969 C515.5781,359.7969 516.1875,359.9531 516.6563,360.2031 C517.1406,360.4844 517.3125,360.7031 517.4063,361.1094 C517.4688,361.5156 517.5,361.6406 517.6406,361.7656 C517.7813,361.9063 518.0156,362.0156 518.2344,362.0156 C518.5,362.0156 518.7656,361.875 518.9375,361.6563 C519.0469,361.5 519.0781,361.3125 519.0781,360.8906 L519.0781,359.4688 C519.0781,359.0313 519.0625,358.9063 518.9688,358.75 C518.8125,358.4844 518.5313,358.3438 518.2344,358.3438 C517.9375,358.3438 517.7344,358.4375 517.5156,358.75 L517.3438,358.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="128" x="529" y="367.8467">ResourceReleaser</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="104" x="665" y="344"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="102" x="666" y="356.1387">PooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="501" x2="765" y1="379" y2="379"/><line style="stroke:#181818;stroke-width:0.5;" x1="501" x2="765" y1="387" y2="387"/></g><!--class Closeable--><g id="elem_Closeable"><rect codeLine="17" fill="#F1F1F1" height="48" id="Closeable" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="102" x="434" y="463"/><ellipse cx="449" cy="479" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M449.9531,475.7813 L451.6719,475.7813 C452.0625,475.7813 452.25,475.75 452.375,475.6719 C452.6406,475.5156 452.7813,475.2344 452.7813,474.9375 C452.7813,474.6719 452.6719,474.4063 452.4375,474.2344 C452.2656,474.125 452.125,474.0938 451.6719,474.0938 L446.5313,474.0938 C446.0938,474.0938 445.9688,474.1094 445.8125,474.2031 C445.5625,474.3594 445.4063,474.6563 445.4063,474.9375 C445.4063,475.2188 445.5469,475.4688 445.7656,475.6406 C445.9219,475.75 446.1094,475.7813 446.5313,475.7813 L448.25,475.7813 L448.25,482.2969 L446.5313,482.2969 C446.0938,482.2969 445.9688,482.3125 445.8125,482.4219 C445.5625,482.5781 445.4063,482.8594 445.4063,483.1563 C445.4063,483.4063 445.5469,483.6719 445.7656,483.8281 C445.9219,483.9531 446.125,484 446.5313,484 L451.6719,484 C452.4219,484 452.7813,483.7188 452.7813,483.1563 C452.7813,482.875 452.6719,482.625 452.4375,482.4531 C452.2656,482.3281 452.125,482.2969 451.6719,482.2969 L449.9531,482.2969 L449.9531,475.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="70" x="463" y="483.8467">Closeable</text><line style="stroke:#181818;stroke-width:0.5;" x1="435" x2="535" y1="495" y2="495"/><line style="stroke:#181818;stroke-width:0.5;" x1="435" x2="535" y1="503" y2="503"/></g><!--class CloseableReference2--><g id="elem_CloseableReference2"><rect codeLine="20" fill="#F1F1F1" height="48" id="CloseableReference2" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="268" x="156" y="587"/><ellipse cx="171" cy="603" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M173.3438,598.6719 C172.4063,598.2344 171.8125,598.0938 170.9375,598.0938 C168.3125,598.0938 166.3125,600.1719 166.3125,602.8906 L166.3125,604.0156 C166.3125,606.5938 168.4219,608.4844 171.3125,608.4844 C172.5313,608.4844 173.6875,608.1875 174.4375,607.6406 C175.0156,607.2344 175.3438,606.7813 175.3438,606.3906 C175.3438,605.9375 174.9531,605.5469 174.4844,605.5469 C174.2656,605.5469 174.0625,605.625 173.875,605.8125 C173.4219,606.2969 173.4219,606.2969 173.2344,606.3906 C172.8125,606.6563 172.125,606.7813 171.3594,606.7813 C169.3125,606.7813 168.0156,605.6875 168.0156,603.9844 L168.0156,602.8906 C168.0156,601.1094 169.2656,599.7969 171,599.7969 C171.5781,599.7969 172.1875,599.9531 172.6563,600.2031 C173.1406,600.4844 173.3125,600.7031 173.4063,601.1094 C173.4688,601.5156 173.5,601.6406 173.6406,601.7656 C173.7813,601.9063 174.0156,602.0156 174.2344,602.0156 C174.5,602.0156 174.7656,601.875 174.9375,601.6563 C175.0469,601.5 175.0781,601.3125 175.0781,600.8906 L175.0781,599.4688 C175.0781,599.0313 175.0625,598.9063 174.9688,598.75 C174.8125,598.4844 174.5313,598.3438 174.2344,598.3438 C173.9375,598.3438 173.7344,598.4375 173.5156,598.75 L173.3438,598.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="145" x="185" y="607.8467">CloseableReference</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="89" x="338" y="584"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="87" x="339" y="596.1387">MemoryChunk</text><line style="stroke:#181818;stroke-width:0.5;" x1="157" x2="423" y1="619" y2="619"/><line style="stroke:#181818;stroke-width:0.5;" x1="157" x2="423" y1="627" y2="627"/></g><!--class MemoryChunkPool--><g id="elem_MemoryChunkPool"><rect codeLine="22" fill="#F1F1F1" height="48" id="MemoryChunkPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="165" x="502.5" y="703"/><ellipse cx="517.5" cy="719" fill="#A9DCDF" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M519.5781,720.8125 L519.9688,721.7969 L519.5781,721.7969 C519.125,721.7969 519.0156,721.8125 518.8594,721.9219 C518.6094,722.0781 518.4531,722.3594 518.4531,722.6563 C518.4531,722.9219 518.5938,723.1719 518.8125,723.3281 C518.9531,723.4531 519.1563,723.5 519.5781,723.5 L521.9375,723.5 C522.2969,723.5 522.5156,723.4688 522.6563,723.375 C522.9063,723.2344 523.0625,722.9375 523.0625,722.6563 C523.0625,722.375 522.9219,722.125 522.7031,721.9688 C522.5313,721.8281 522.375,721.7969 521.9063,721.7969 L518.5156,713.5938 L514.8438,713.5938 C514.3906,713.5938 514.2656,713.6094 514.1094,713.7031 C513.8594,713.875 513.7031,714.1563 513.7031,714.4375 C513.7031,714.7188 513.8438,714.9688 514.0625,715.1406 C514.2344,715.25 514.4063,715.2813 514.8438,715.2813 L515.9219,715.2813 L513.2813,721.7969 C512.8594,721.7969 512.7031,721.8125 512.5469,721.9219 C512.2969,722.0781 512.1406,722.3594 512.1406,722.6563 C512.1406,723.2188 512.5156,723.5 513.2656,723.5 L515.5313,723.5 C515.8906,723.5 516.1094,723.4688 516.2344,723.375 C516.5,723.2344 516.6406,722.9375 516.6406,722.6563 C516.6406,722.375 516.5156,722.125 516.2969,721.9531 C516.125,721.8281 515.9844,721.7969 515.5313,721.7969 L515.1406,721.7969 L515.5313,720.8125 L519.5781,720.8125 Z M518.875,719.1094 L516.2031,719.1094 L517.5469,715.8438 L518.875,719.1094 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="133" x="531.5" y="723.8467">MemoryChunkPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="503.5" x2="666.5" y1="735" y2="735"/><line style="stroke:#181818;stroke-width:0.5;" x1="503.5" x2="666.5" y1="743" y2="743"/></g><!--class ResourceReleaser2--><g id="elem_ResourceReleaser2"><rect codeLine="23" fill="#F1F1F1" height="64.2969" id="ResourceReleaser2" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="251" x="459.5" y="579"/><ellipse cx="474.5" cy="595" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M476.8438,590.6719 C475.9063,590.2344 475.3125,590.0938 474.4375,590.0938 C471.8125,590.0938 469.8125,592.1719 469.8125,594.8906 L469.8125,596.0156 C469.8125,598.5938 471.9219,600.4844 474.8125,600.4844 C476.0313,600.4844 477.1875,600.1875 477.9375,599.6406 C478.5156,599.2344 478.8438,598.7813 478.8438,598.3906 C478.8438,597.9375 478.4531,597.5469 477.9844,597.5469 C477.7656,597.5469 477.5625,597.625 477.375,597.8125 C476.9219,598.2969 476.9219,598.2969 476.7344,598.3906 C476.3125,598.6563 475.625,598.7813 474.8594,598.7813 C472.8125,598.7813 471.5156,597.6875 471.5156,595.9844 L471.5156,594.8906 C471.5156,593.1094 472.7656,591.7969 474.5,591.7969 C475.0781,591.7969 475.6875,591.9531 476.1563,592.2031 C476.6406,592.4844 476.8125,592.7031 476.9063,593.1094 C476.9688,593.5156 477,593.6406 477.1406,593.7656 C477.2813,593.9063 477.5156,594.0156 477.7344,594.0156 C478,594.0156 478.2656,593.875 478.4375,593.6563 C478.5469,593.5 478.5781,593.3125 478.5781,592.8906 L478.5781,591.4688 C478.5781,591.0313 478.5625,590.9063 478.4688,590.75 C478.3125,590.4844 478.0313,590.3438 477.7344,590.3438 C477.4375,590.3438 477.2344,590.4375 477.0156,590.75 L476.8438,590.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="128" x="488.5" y="599.8467">ResourceReleaser</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="89" x="624.5" y="576"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="87" x="625.5" y="588.1387">MemoryChunk</text><line style="stroke:#181818;stroke-width:0.5;" x1="460.5" x2="709.5" y1="611" y2="611"/><line style="stroke:#181818;stroke-width:0.5;" x1="460.5" x2="709.5" y1="619" y2="619"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="62" x="465.5" y="635.9951">release()</text></g><!--class MemoryChunk--><g id="elem_MemoryChunk"><rect codeLine="28" fill="#F1F1F1" height="48" id="MemoryChunk" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="135" x="222.5" y="703"/><ellipse cx="237.5" cy="719" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M238.4531,715.7813 L240.1719,715.7813 C240.5625,715.7813 240.75,715.75 240.875,715.6719 C241.1406,715.5156 241.2813,715.2344 241.2813,714.9375 C241.2813,714.6719 241.1719,714.4063 240.9375,714.2344 C240.7656,714.125 240.625,714.0938 240.1719,714.0938 L235.0313,714.0938 C234.5938,714.0938 234.4688,714.1094 234.3125,714.2031 C234.0625,714.3594 233.9063,714.6563 233.9063,714.9375 C233.9063,715.2188 234.0469,715.4688 234.2656,715.6406 C234.4219,715.75 234.6094,715.7813 235.0313,715.7813 L236.75,715.7813 L236.75,722.2969 L235.0313,722.2969 C234.5938,722.2969 234.4688,722.3125 234.3125,722.4219 C234.0625,722.5781 233.9063,722.8594 233.9063,723.1563 C233.9063,723.4063 234.0469,723.6719 234.2656,723.8281 C234.4219,723.9531 234.625,724 235.0313,724 L240.1719,724 C240.9219,724 241.2813,723.7188 241.2813,723.1563 C241.2813,722.875 241.1719,722.625 240.9375,722.4531 C240.7656,722.3281 240.625,722.2969 240.1719,722.2969 L238.4531,722.2969 L238.4531,715.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="103" x="251.5" y="723.8467">MemoryChunk</text><line style="stroke:#181818;stroke-width:0.5;" x1="223.5" x2="356.5" y1="735" y2="735"/><line style="stroke:#181818;stroke-width:0.5;" x1="223.5" x2="356.5" y1="743" y2="743"/></g><!--reverse link EncodedImage to CloseableReference--><g id="link_EncodedImage_CloseableReference"><path codeLine="3" d="M342,67 C342,84.658 342,96.941 342,114.678 " fill="none" id="EncodedImage-backto-CloseableReference" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="342,55,338,61,342,67,346,61,342,55" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link PooledByteBuffer to MemoryPooledByteBuffer--><g id="link_PooledByteBuffer_MemoryPooledByteBuffer"><path codeLine="7" d="M355.7062,408.7788 C341.0912,425.9548 332.642,435.884 316.586,454.755 " fill="none" id="PooledByteBuffer-backto-MemoryPooledByteBuffer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="367.371,395.07,351.1366,404.8906,360.2758,412.6671,367.371,395.07" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CloseableReference to DefaultCloseableReference--><g id="link_CloseableReference_DefaultCloseableReference"><path codeLine="9" d="M293.3384,173.2181 C264.3644,192.9961 237.704,211.196 208.745,230.965 " fill="none" id="CloseableReference-backto-DefaultCloseableReference" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="308.205,163.07,289.9557,168.2626,296.7211,178.1736,308.205,163.07" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CloseableReference to SharedReference--><g id="link_CloseableReference_SharedReference"><path codeLine="13" d="M385.9267,169.808 C411.3347,187.049 436.41,204.064 464.27,222.969 " fill="none" id="CloseableReference-backto-SharedReference" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="375.997,163.07,378.7159,169.7489,385.9267,169.808,383.2079,163.1291,375.997,163.07" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link SharedReference to PooledByteBuffer--><g id="link_SharedReference_PooledByteBuffer"><path codeLine="14" d="M467.5887,295.3081 C447.2457,314.1621 430.539,329.647 411.984,346.845 " fill="none" id="SharedReference-backto-PooledByteBuffer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="476.39,287.151,469.2703,288.2958,467.5887,295.3081,474.7084,294.1633,476.39,287.151" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link SharedReference to ResourceReleaser--><g id="link_SharedReference_ResourceReleaser"><path codeLine="16" d="M552.4113,295.3081 C572.7543,314.1621 589.461,329.647 608.016,346.845 " fill="none" id="SharedReference-backto-ResourceReleaser" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="543.61,287.151,545.2916,294.1633,552.4113,295.3081,550.7297,288.2958,543.61,287.151" style="stroke:#181818;stroke-width:1.0;"/></g><!--link PooledByteBuffer to Closeable--><g id="link_PooledByteBuffer_Closeable"><path codeLine="18" d="M406.832,395.07 C423.834,414.848 436.4702,429.5462 453.4642,449.3152 " fill="none" id="PooledByteBuffer-to-Closeable" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="465.198,462.965,458.0142,445.4039,448.9143,453.2264,465.198,462.965" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link MemoryPooledByteBuffer to CloseableReference2--><g id="link_MemoryPooledByteBuffer_CloseableReference2"><path codeLine="21" d="M290,531.101 C290,552.139 290,567.481 290,586.661 " fill="none" id="MemoryPooledByteBuffer-backto-CloseableReference2" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="290,519.101,286,525.101,290,531.101,294,525.101,290,519.101" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link ResourceReleaser2 to MemoryChunkPool--><g id="link_ResourceReleaser2_MemoryChunkPool"><path codeLine="26" d="M585,661.151 C585,680.0054 585,685.647 585,702.8446 " fill="none" id="ResourceReleaser2-backto-MemoryChunkPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="585,643.151,579,661.151,591,661.151,585,643.151" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CloseableReference2 to ResourceReleaser2--><g id="link_CloseableReference2_ResourceReleaser2"><path codeLine="27" d="M436.248,611 C447.97,611 447.691,611 459.413,611 " fill="none" id="CloseableReference2-backto-ResourceReleaser2" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="424.248,611,430.248,615,436.248,611,430.248,607,424.248,611" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CloseableReference2 to MemoryChunk--><g id="link_CloseableReference2_MemoryChunk"><path codeLine="29" d="M290,647.07 C290,666.8481 290,683.1961 290,702.9647 " fill="none" id="CloseableReference2-backto-MemoryChunk" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="290,635.07,286,641.07,290,647.07,294,641.07,290,635.07" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[ZPAzRi8m58LtFuN5r29voOmoa7ReW8Je4roScnBLiP5_1bJwxdM8IoFx1ZMRutC-d_lJQu-s0ubyRup2Tdlnk0rTXvP91SxnHXc7S5HumFWJjSHDhgpPgvQcnVPjW0_aQo48LyBjS33saXFu5-FnawFhwPbziqAmkKOgRKxa5-mWAF-llALeUc2HaTvuFu75zW4v5T9hpuSeQqpGFfP3l3TsASEnx7pJB5HxG6U2bH6e41nQeaYAbjjOVv__FMFPV26kzUm-HLWHhPucr9o2_gnN7AZrgTZ23j1xKp4uEcz1UZw3Z-RV64KhYX2veafZijFvjd4Pd8jm7gikhCGignYT4FwrTiPUi8kvvWS0]--></g></svg>

<h3 id="DiskCacheWriteProducer"><a href="#DiskCacheWriteProducer" class="headerlink" title="DiskCacheWriteProducer"></a>DiskCacheWriteProducer</h3><p>DiskCacheWriteProducer用于缓存原始图片数据，包括两级缓存：内存和磁盘。</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="563px" preserveAspectRatio="none" style="width:813px;height:563px;background:#FFFFFF;" version="1.1" viewBox="0 0 813 563" width="813px" zoomAndPan="magnify"><defs/><g><!--class DiskCacheWriteProducer--><g id="elem_DiskCacheWriteProducer"><rect codeLine="1" fill="#F1F1F1" height="80.5938" id="DiskCacheWriteProducer" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="247" x="7" y="7"/><ellipse cx="38.2" cy="23" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M40.5438,18.6719 C39.6063,18.2344 39.0125,18.0938 38.1375,18.0938 C35.5125,18.0938 33.5125,20.1719 33.5125,22.8906 L33.5125,24.0156 C33.5125,26.5938 35.6219,28.4844 38.5125,28.4844 C39.7313,28.4844 40.8875,28.1875 41.6375,27.6406 C42.2156,27.2344 42.5438,26.7813 42.5438,26.3906 C42.5438,25.9375 42.1531,25.5469 41.6844,25.5469 C41.4656,25.5469 41.2625,25.625 41.075,25.8125 C40.6219,26.2969 40.6219,26.2969 40.4344,26.3906 C40.0125,26.6563 39.325,26.7813 38.5594,26.7813 C36.5125,26.7813 35.2156,25.6875 35.2156,23.9844 L35.2156,22.8906 C35.2156,21.1094 36.4656,19.7969 38.2,19.7969 C38.7781,19.7969 39.3875,19.9531 39.8563,20.2031 C40.3406,20.4844 40.5125,20.7031 40.6063,21.1094 C40.6688,21.5156 40.7,21.6406 40.8406,21.7656 C40.9813,21.9063 41.2156,22.0156 41.4344,22.0156 C41.7,22.0156 41.9656,21.875 42.1375,21.6563 C42.2469,21.5 42.2781,21.3125 42.2781,20.8906 L42.2781,19.4688 C42.2781,19.0313 42.2625,18.9063 42.1688,18.75 C42.0125,18.4844 41.7313,18.3438 41.4344,18.3438 C41.1375,18.3438 40.9344,18.4375 40.7156,18.75 L40.5438,18.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="179" x="55.8" y="27.8467">DiskCacheWriteProducer</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="253" y1="39" y2="39"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="205" x="13" y="55.9951">mDefaultBufferedDiskCache</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="235" x="13" y="72.292">mSmallImageBufferedDiskCache</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="253" y1="79.5938" y2="79.5938"/></g><!--class BufferedDiskCache--><g id="elem_BufferedDiskCache"><rect fill="#F1F1F1" height="48" id="BufferedDiskCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="170" x="297.5" y="23"/><ellipse cx="312.5" cy="39" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M314.8438,34.6719 C313.9063,34.2344 313.3125,34.0938 312.4375,34.0938 C309.8125,34.0938 307.8125,36.1719 307.8125,38.8906 L307.8125,40.0156 C307.8125,42.5938 309.9219,44.4844 312.8125,44.4844 C314.0313,44.4844 315.1875,44.1875 315.9375,43.6406 C316.5156,43.2344 316.8438,42.7813 316.8438,42.3906 C316.8438,41.9375 316.4531,41.5469 315.9844,41.5469 C315.7656,41.5469 315.5625,41.625 315.375,41.8125 C314.9219,42.2969 314.9219,42.2969 314.7344,42.3906 C314.3125,42.6563 313.625,42.7813 312.8594,42.7813 C310.8125,42.7813 309.5156,41.6875 309.5156,39.9844 L309.5156,38.8906 C309.5156,37.1094 310.7656,35.7969 312.5,35.7969 C313.0781,35.7969 313.6875,35.9531 314.1563,36.2031 C314.6406,36.4844 314.8125,36.7031 314.9063,37.1094 C314.9688,37.5156 315,37.6406 315.1406,37.7656 C315.2813,37.9063 315.5156,38.0156 315.7344,38.0156 C316,38.0156 316.2656,37.875 316.4375,37.6563 C316.5469,37.5 316.5781,37.3125 316.5781,36.8906 L316.5781,35.4688 C316.5781,35.0313 316.5625,34.9063 316.4688,34.75 C316.3125,34.4844 316.0313,34.3438 315.7344,34.3438 C315.4375,34.3438 315.2344,34.4375 315.0156,34.75 L314.8438,34.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="138" x="326.5" y="43.8467">BufferedDiskCache</text><line style="stroke:#181818;stroke-width:0.5;" x1="298.5" x2="466.5" y1="55" y2="55"/><line style="stroke:#181818;stroke-width:0.5;" x1="298.5" x2="466.5" y1="63" y2="63"/></g><!--class StagingArea--><g id="elem_StagingArea"><rect codeLine="8" fill="#F1F1F1" height="64.2969" id="StagingArea" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="297" x="32" y="159.5"/><ellipse cx="132.25" cy="175.5" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M134.5938,171.1719 C133.6563,170.7344 133.0625,170.5938 132.1875,170.5938 C129.5625,170.5938 127.5625,172.6719 127.5625,175.3906 L127.5625,176.5156 C127.5625,179.0938 129.6719,180.9844 132.5625,180.9844 C133.7813,180.9844 134.9375,180.6875 135.6875,180.1406 C136.2656,179.7344 136.5938,179.2813 136.5938,178.8906 C136.5938,178.4375 136.2031,178.0469 135.7344,178.0469 C135.5156,178.0469 135.3125,178.125 135.125,178.3125 C134.6719,178.7969 134.6719,178.7969 134.4844,178.8906 C134.0625,179.1563 133.375,179.2813 132.6094,179.2813 C130.5625,179.2813 129.2656,178.1875 129.2656,176.4844 L129.2656,175.3906 C129.2656,173.6094 130.5156,172.2969 132.25,172.2969 C132.8281,172.2969 133.4375,172.4531 133.9063,172.7031 C134.3906,172.9844 134.5625,173.2031 134.6563,173.6094 C134.7188,174.0156 134.75,174.1406 134.8906,174.2656 C135.0313,174.4063 135.2656,174.5156 135.4844,174.5156 C135.75,174.5156 136.0156,174.375 136.1875,174.1563 C136.2969,174 136.3281,173.8125 136.3281,173.3906 L136.3281,171.9688 C136.3281,171.5313 136.3125,171.4063 136.2188,171.25 C136.0625,170.9844 135.7813,170.8438 135.4844,170.8438 C135.1875,170.8438 134.9844,170.9375 134.7656,171.25 L134.5938,171.1719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="88" x="152.75" y="180.3467">StagingArea</text><line style="stroke:#181818;stroke-width:0.5;" x1="33" x2="328" y1="191.5" y2="191.5"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="285" x="38" y="208.4951">Map&lt;CacheKey, EncodedImage&gt; mMap</text><line style="stroke:#181818;stroke-width:0.5;" x1="33" x2="328" y1="215.7969" y2="215.7969"/></g><!--class FileCache--><g id="elem_FileCache"><rect codeLine="11" fill="#F1F1F1" height="80.5938" id="FileCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="442" x="364.5" y="151"/><ellipse cx="546.25" cy="167" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M547.2031,163.7813 L548.9219,163.7813 C549.3125,163.7813 549.5,163.75 549.625,163.6719 C549.8906,163.5156 550.0313,163.2344 550.0313,162.9375 C550.0313,162.6719 549.9219,162.4063 549.6875,162.2344 C549.5156,162.125 549.375,162.0938 548.9219,162.0938 L543.7813,162.0938 C543.3438,162.0938 543.2188,162.1094 543.0625,162.2031 C542.8125,162.3594 542.6563,162.6563 542.6563,162.9375 C542.6563,163.2188 542.7969,163.4688 543.0156,163.6406 C543.1719,163.75 543.3594,163.7813 543.7813,163.7813 L545.5,163.7813 L545.5,170.2969 L543.7813,170.2969 C543.3438,170.2969 543.2188,170.3125 543.0625,170.4219 C542.8125,170.5781 542.6563,170.8594 542.6563,171.1563 C542.6563,171.4063 542.7969,171.6719 543.0156,171.8281 C543.1719,171.9531 543.375,172 543.7813,172 L548.9219,172 C549.6719,172 550.0313,171.7188 550.0313,171.1563 C550.0313,170.875 549.9219,170.625 549.6875,170.4531 C549.5156,170.3281 549.375,170.2969 548.9219,170.2969 L547.2031,170.2969 L547.2031,163.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="70" x="566.75" y="171.8467">FileCache</text><line style="stroke:#181818;stroke-width:0.5;" x1="365.5" x2="805.5" y1="183" y2="183"/><line style="stroke:#181818;stroke-width:0.5;" x1="365.5" x2="805.5" y1="191" y2="191"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="317" x="370.5" y="207.9951">BinaryResource getResource(CacheKey key)</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="430" x="370.5" y="224.292">BinaryResource insert(CacheKey key, WriterCallback writer)</text></g><!--class DiskStorageCache--><g id="elem_DiskStorageCache"><rect fill="#F1F1F1" height="48" id="DiskStorageCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="164" x="503.5" y="292"/><ellipse cx="518.5" cy="308" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M520.8438,303.6719 C519.9063,303.2344 519.3125,303.0938 518.4375,303.0938 C515.8125,303.0938 513.8125,305.1719 513.8125,307.8906 L513.8125,309.0156 C513.8125,311.5938 515.9219,313.4844 518.8125,313.4844 C520.0313,313.4844 521.1875,313.1875 521.9375,312.6406 C522.5156,312.2344 522.8438,311.7813 522.8438,311.3906 C522.8438,310.9375 522.4531,310.5469 521.9844,310.5469 C521.7656,310.5469 521.5625,310.625 521.375,310.8125 C520.9219,311.2969 520.9219,311.2969 520.7344,311.3906 C520.3125,311.6563 519.625,311.7813 518.8594,311.7813 C516.8125,311.7813 515.5156,310.6875 515.5156,308.9844 L515.5156,307.8906 C515.5156,306.1094 516.7656,304.7969 518.5,304.7969 C519.0781,304.7969 519.6875,304.9531 520.1563,305.2031 C520.6406,305.4844 520.8125,305.7031 520.9063,306.1094 C520.9688,306.5156 521,306.6406 521.1406,306.7656 C521.2813,306.9063 521.5156,307.0156 521.7344,307.0156 C522,307.0156 522.2656,306.875 522.4375,306.6563 C522.5469,306.5 522.5781,306.3125 522.5781,305.8906 L522.5781,304.4688 C522.5781,304.0313 522.5625,303.9063 522.4688,303.75 C522.3125,303.4844 522.0313,303.3438 521.7344,303.3438 C521.4375,303.3438 521.2344,303.4375 521.0156,303.75 L520.8438,303.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="132" x="532.5" y="312.8467">DiskStorageCache</text><line style="stroke:#181818;stroke-width:0.5;" x1="504.5" x2="666.5" y1="324" y2="324"/><line style="stroke:#181818;stroke-width:0.5;" x1="504.5" x2="666.5" y1="332" y2="332"/></g><!--class DiskStorage--><g id="elem_DiskStorage"><rect codeLine="16" fill="#F1F1F1" height="48" id="DiskStorage" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="118" x="526.5" y="400"/><ellipse cx="541.5" cy="416" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M542.4531,412.7813 L544.1719,412.7813 C544.5625,412.7813 544.75,412.75 544.875,412.6719 C545.1406,412.5156 545.2813,412.2344 545.2813,411.9375 C545.2813,411.6719 545.1719,411.4063 544.9375,411.2344 C544.7656,411.125 544.625,411.0938 544.1719,411.0938 L539.0313,411.0938 C538.5938,411.0938 538.4688,411.1094 538.3125,411.2031 C538.0625,411.3594 537.9063,411.6563 537.9063,411.9375 C537.9063,412.2188 538.0469,412.4688 538.2656,412.6406 C538.4219,412.75 538.6094,412.7813 539.0313,412.7813 L540.75,412.7813 L540.75,419.2969 L539.0313,419.2969 C538.5938,419.2969 538.4688,419.3125 538.3125,419.4219 C538.0625,419.5781 537.9063,419.8594 537.9063,420.1563 C537.9063,420.4063 538.0469,420.6719 538.2656,420.8281 C538.4219,420.9531 538.625,421 539.0313,421 L544.1719,421 C544.9219,421 545.2813,420.7188 545.2813,420.1563 C545.2813,419.875 545.1719,419.625 544.9375,419.4531 C544.7656,419.3281 544.625,419.2969 544.1719,419.2969 L542.4531,419.2969 L542.4531,412.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="86" x="555.5" y="420.8467">DiskStorage</text><line style="stroke:#181818;stroke-width:0.5;" x1="527.5" x2="643.5" y1="432" y2="432"/><line style="stroke:#181818;stroke-width:0.5;" x1="527.5" x2="643.5" y1="440" y2="440"/></g><!--class DynamicDefaultDiskStorage--><g id="elem_DynamicDefaultDiskStorage"><rect fill="#F1F1F1" height="48" id="DynamicDefaultDiskStorage" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="235" x="468" y="508"/><ellipse cx="483" cy="524" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M485.3438,519.6719 C484.4063,519.2344 483.8125,519.0938 482.9375,519.0938 C480.3125,519.0938 478.3125,521.1719 478.3125,523.8906 L478.3125,525.0156 C478.3125,527.5938 480.4219,529.4844 483.3125,529.4844 C484.5313,529.4844 485.6875,529.1875 486.4375,528.6406 C487.0156,528.2344 487.3438,527.7813 487.3438,527.3906 C487.3438,526.9375 486.9531,526.5469 486.4844,526.5469 C486.2656,526.5469 486.0625,526.625 485.875,526.8125 C485.4219,527.2969 485.4219,527.2969 485.2344,527.3906 C484.8125,527.6563 484.125,527.7813 483.3594,527.7813 C481.3125,527.7813 480.0156,526.6875 480.0156,524.9844 L480.0156,523.8906 C480.0156,522.1094 481.2656,520.7969 483,520.7969 C483.5781,520.7969 484.1875,520.9531 484.6563,521.2031 C485.1406,521.4844 485.3125,521.7031 485.4063,522.1094 C485.4688,522.5156 485.5,522.6406 485.6406,522.7656 C485.7813,522.9063 486.0156,523.0156 486.2344,523.0156 C486.5,523.0156 486.7656,522.875 486.9375,522.6563 C487.0469,522.5 487.0781,522.3125 487.0781,521.8906 L487.0781,520.4688 C487.0781,520.0313 487.0625,519.9063 486.9688,519.75 C486.8125,519.4844 486.5313,519.3438 486.2344,519.3438 C485.9375,519.3438 485.7344,519.4375 485.5156,519.75 L485.3438,519.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="203" x="497" y="528.8467">DynamicDefaultDiskStorage</text><line style="stroke:#181818;stroke-width:0.5;" x1="469" x2="702" y1="540" y2="540"/><line style="stroke:#181818;stroke-width:0.5;" x1="469" x2="702" y1="548" y2="548"/></g><!--reverse link DiskCacheWriteProducer to BufferedDiskCache--><g id="link_DiskCacheWriteProducer_BufferedDiskCache"><path codeLine="5" d="M267.5,51 C281.069,51 283.457,50.765 297.47,50.41 " fill="none" id="DiskCacheWriteProducer-backto-BufferedDiskCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="255.5,51,261.5,55,267.5,51,261.5,47,255.5,51" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DiskCacheWriteProducer to BufferedDiskCache--><g id="link_DiskCacheWriteProducer_BufferedDiskCache"><path codeLine="6" d="M267.5,67 C281.122,67 283.47,65.846 297.41,64.092 " fill="none" id="DiskCacheWriteProducer-backto-BufferedDiskCache-1" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="255.5,67,261.5,71,267.5,67,261.5,63,255.5,67" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BufferedDiskCache to StagingArea--><g id="link_BufferedDiskCache_StagingArea"><path codeLine="7" d="M339.7903,78.1293 C305.8043,102.1043 262.369,132.746 224.72,159.305 " fill="none" id="BufferedDiskCache-backto-StagingArea" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="349.596,71.212,342.3874,71.4021,339.7903,78.1293,346.9989,77.9392,349.596,71.212" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link FileCache to DiskStorageCache--><g id="link_FileCache_DiskStorageCache"><path codeLine="15" d="M585.5,250.272 C585.5,269.973 585.5,275.069 585.5,291.843 " fill="none" id="FileCache-backto-DiskStorageCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="585.5,232.272,579.5,250.272,591.5,250.272,585.5,232.272" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DiskStorage to DynamicDefaultDiskStorage--><g id="link_DiskStorage_DynamicDefaultDiskStorage"><path codeLine="17" d="M585.5,466 C585.5,483.6584 585.5,489.9408 585.5,507.6784 " fill="none" id="DiskStorage-backto-DynamicDefaultDiskStorage" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="585.5,448,579.5,466,591.5,466,585.5,448" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link BufferedDiskCache to FileCache--><g id="link_BufferedDiskCache_FileCache"><path codeLine="18" d="M425.3887,78.1065 C456.0597,99.6365 492.514,125.227 529.034,150.863 " fill="none" id="BufferedDiskCache-backto-FileCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="415.567,71.212,418.1797,77.9332,425.3887,78.1065,422.776,71.3853,415.567,71.212" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DiskStorageCache to DiskStorage--><g id="link_DiskStorageCache_DiskStorage"><path codeLine="19" d="M585.5,352 C585.5,369.658 585.5,381.941 585.5,399.678 " fill="none" id="DiskStorageCache-backto-DiskStorage" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="585.5,340,581.5,346,585.5,352,589.5,346,585.5,340" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[VL51Ri8m4Bpx5Nii5Nm08QG2hLHLIAWvzBnrDgaLswdMZge8-7jT9u1RJ7soTsPdTiTIetEmKQvPe_oWDrQUTjoMdII6lO1mp8OgxBHVTLL5JEMPFA25GQsV3TPqJJYAlF9yVbCKxcTmBNHJvX_tl5AEDeF2Owri_S24GiP8aigOmnO_5x7ZXVefF5hPbbH6woMO08PjbVN45Kg29wLfa1-QLyeYzw_aseu3N9C_tUzEcj1GFycHbNN4_XTl2Z48NeVjtr4sy1MVap33nNbn29lzx5dubiEOGm2N6HD89FUnhxTeb1o_AQNc4ppRYh-E4KwAtm00]--></g></svg>

<p>DiskCacheWriteProducer接收到下级Producer的EncodedImage后就会调用<code>BufferedDiskCache#put()</code>进行缓存。BufferedDiskCache在缓存图片时，会先把图片（EncodedImage）保存到StagingArea（mMap）中，即内存缓存，下次获取时也会优先从StagingArea中获取内存中的图片缓存。然后，在子线程中写入磁盘缓存。</p>
<h3 id="DiskCacheReadProducer"><a href="#DiskCacheReadProducer" class="headerlink" title="DiskCacheReadProducer"></a>DiskCacheReadProducer</h3><?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="94px" preserveAspectRatio="none" style="width:474px;height:94px;background:#FFFFFF;" version="1.1" viewBox="0 0 474 94" width="474px" zoomAndPan="magnify"><defs/><g><!--class DiskCacheReadProducer--><g id="elem_DiskCacheReadProducer"><rect codeLine="1" fill="#F1F1F1" height="80.5938" id="DiskCacheReadProducer" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="247" x="7" y="7"/><ellipse cx="40" cy="23" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M42.3438,18.6719 C41.4063,18.2344 40.8125,18.0938 39.9375,18.0938 C37.3125,18.0938 35.3125,20.1719 35.3125,22.8906 L35.3125,24.0156 C35.3125,26.5938 37.4219,28.4844 40.3125,28.4844 C41.5313,28.4844 42.6875,28.1875 43.4375,27.6406 C44.0156,27.2344 44.3438,26.7813 44.3438,26.3906 C44.3438,25.9375 43.9531,25.5469 43.4844,25.5469 C43.2656,25.5469 43.0625,25.625 42.875,25.8125 C42.4219,26.2969 42.4219,26.2969 42.2344,26.3906 C41.8125,26.6563 41.125,26.7813 40.3594,26.7813 C38.3125,26.7813 37.0156,25.6875 37.0156,23.9844 L37.0156,22.8906 C37.0156,21.1094 38.2656,19.7969 40,19.7969 C40.5781,19.7969 41.1875,19.9531 41.6563,20.2031 C42.1406,20.4844 42.3125,20.7031 42.4063,21.1094 C42.4688,21.5156 42.5,21.6406 42.6406,21.7656 C42.7813,21.9063 43.0156,22.0156 43.2344,22.0156 C43.5,22.0156 43.7656,21.875 43.9375,21.6563 C44.0469,21.5 44.0781,21.3125 44.0781,20.8906 L44.0781,19.4688 C44.0781,19.0313 44.0625,18.9063 43.9688,18.75 C43.8125,18.4844 43.5313,18.3438 43.2344,18.3438 C42.9375,18.3438 42.7344,18.4375 42.5156,18.75 L42.3438,18.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="175" x="58" y="27.8467">DiskCacheReadProducer</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="253" y1="39" y2="39"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="205" x="13" y="55.9951">mDefaultBufferedDiskCache</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="235" x="13" y="72.292">mSmallImageBufferedDiskCache</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="253" y1="79.5938" y2="79.5938"/></g><!--class BufferedDiskCache--><g id="elem_BufferedDiskCache"><rect fill="#F1F1F1" height="48" id="BufferedDiskCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="170" x="297.5" y="23"/><ellipse cx="312.5" cy="39" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M314.8438,34.6719 C313.9063,34.2344 313.3125,34.0938 312.4375,34.0938 C309.8125,34.0938 307.8125,36.1719 307.8125,38.8906 L307.8125,40.0156 C307.8125,42.5938 309.9219,44.4844 312.8125,44.4844 C314.0313,44.4844 315.1875,44.1875 315.9375,43.6406 C316.5156,43.2344 316.8438,42.7813 316.8438,42.3906 C316.8438,41.9375 316.4531,41.5469 315.9844,41.5469 C315.7656,41.5469 315.5625,41.625 315.375,41.8125 C314.9219,42.2969 314.9219,42.2969 314.7344,42.3906 C314.3125,42.6563 313.625,42.7813 312.8594,42.7813 C310.8125,42.7813 309.5156,41.6875 309.5156,39.9844 L309.5156,38.8906 C309.5156,37.1094 310.7656,35.7969 312.5,35.7969 C313.0781,35.7969 313.6875,35.9531 314.1563,36.2031 C314.6406,36.4844 314.8125,36.7031 314.9063,37.1094 C314.9688,37.5156 315,37.6406 315.1406,37.7656 C315.2813,37.9063 315.5156,38.0156 315.7344,38.0156 C316,38.0156 316.2656,37.875 316.4375,37.6563 C316.5469,37.5 316.5781,37.3125 316.5781,36.8906 L316.5781,35.4688 C316.5781,35.0313 316.5625,34.9063 316.4688,34.75 C316.3125,34.4844 316.0313,34.3438 315.7344,34.3438 C315.4375,34.3438 315.2344,34.4375 315.0156,34.75 L314.8438,34.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="138" x="326.5" y="43.8467">BufferedDiskCache</text><line style="stroke:#181818;stroke-width:0.5;" x1="298.5" x2="466.5" y1="55" y2="55"/><line style="stroke:#181818;stroke-width:0.5;" x1="298.5" x2="466.5" y1="63" y2="63"/></g><!--reverse link DiskCacheReadProducer to BufferedDiskCache--><g id="link_DiskCacheReadProducer_BufferedDiskCache"><path codeLine="5" d="M267.5,51 C281.069,51 283.457,50.7654 297.47,50.4098 " fill="none" id="DiskCacheReadProducer-backto-BufferedDiskCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="255.5,51,261.5,55,267.5,51,261.5,47,255.5,51" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DiskCacheReadProducer to BufferedDiskCache--><g id="link_DiskCacheReadProducer_BufferedDiskCache"><path codeLine="6" d="M267.5,67 C281.122,67 283.47,65.8457 297.41,64.0918 " fill="none" id="DiskCacheReadProducer-backto-BufferedDiskCache-1" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="255.5,67,261.5,71,267.5,67,261.5,63,255.5,67" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[Iyv9B2vMSCaipdPEJCv83KfDJ0aeoayfJKujKgZcKW22N9VKjCJId1AdqhIqrABK5BXQY6nmRc9EZcTkOdegfe9QBgm6MrdXD5D1IrS1qnnSfk2n6wj10000]--></g></svg>

<p>DiskCacheReadProducer也持有两个BufferedDiskCache，与DiskCacheWriteProducer中的同一个对象实例。从DiskCacheWriteProducer的分析中我们知道图片会优先保存到内存中（StagingArea）,读取时也优先使用内存中的缓存。</p>
<p>DiskCacheReadProducer启动后会先从缓存读取图片，如果存在缓存的图片就不会再调用下一级Producer，直接把结果返回给上一级。如果没有读取到缓存的图片，就会继续调用下一级Producer。</p>
<h3 id="EncodedMemoryCacheProducer"><a href="#EncodedMemoryCacheProducer" class="headerlink" title="EncodedMemoryCacheProducer"></a>EncodedMemoryCacheProducer</h3><?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="389px" preserveAspectRatio="none" style="width:961px;height:389px;background:#FFFFFF;" version="1.1" viewBox="0 0 961 389" width="961px" zoomAndPan="magnify"><defs/><g><!--class MemoryCache--><g id="elem_MemoryCache"><rect codeLine="1" fill="#F1F1F1" height="48" id="MemoryCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="308" x="158" y="118"/><ellipse cx="173" cy="134" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M173.9531,130.7813 L175.6719,130.7813 C176.0625,130.7813 176.25,130.75 176.375,130.6719 C176.6406,130.5156 176.7813,130.2344 176.7813,129.9375 C176.7813,129.6719 176.6719,129.4063 176.4375,129.2344 C176.2656,129.125 176.125,129.0938 175.6719,129.0938 L170.5313,129.0938 C170.0938,129.0938 169.9688,129.1094 169.8125,129.2031 C169.5625,129.3594 169.4063,129.6563 169.4063,129.9375 C169.4063,130.2188 169.5469,130.4688 169.7656,130.6406 C169.9219,130.75 170.1094,130.7813 170.5313,130.7813 L172.25,130.7813 L172.25,137.2969 L170.5313,137.2969 C170.0938,137.2969 169.9688,137.3125 169.8125,137.4219 C169.5625,137.5781 169.4063,137.8594 169.4063,138.1563 C169.4063,138.4063 169.5469,138.6719 169.7656,138.8281 C169.9219,138.9531 170.125,139 170.5313,139 L175.6719,139 C176.4219,139 176.7813,138.7188 176.7813,138.1563 C176.7813,137.875 176.6719,137.625 176.4375,137.4531 C176.2656,137.3281 176.125,137.2969 175.6719,137.2969 L173.9531,137.2969 L173.9531,130.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="103" x="187" y="138.8467">MemoryCache</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="171" x="298" y="115"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="169" x="299" y="127.1387">CacheKey, PooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="159" x2="465" y1="150" y2="150"/><line style="stroke:#181818;stroke-width:0.5;" x1="159" x2="465" y1="158" y2="158"/></g><!--class Producer--><g id="elem_Producer"><rect codeLine="2" fill="#F1F1F1" height="48" id="Producer" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="191" x="477.5" y="10"/><ellipse cx="492.5" cy="26" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M493.4531,22.7813 L495.1719,22.7813 C495.5625,22.7813 495.75,22.75 495.875,22.6719 C496.1406,22.5156 496.2813,22.2344 496.2813,21.9375 C496.2813,21.6719 496.1719,21.4063 495.9375,21.2344 C495.7656,21.125 495.625,21.0938 495.1719,21.0938 L490.0313,21.0938 C489.5938,21.0938 489.4688,21.1094 489.3125,21.2031 C489.0625,21.3594 488.9063,21.6563 488.9063,21.9375 C488.9063,22.2188 489.0469,22.4688 489.2656,22.6406 C489.4219,22.75 489.6094,22.7813 490.0313,22.7813 L491.75,22.7813 L491.75,29.2969 L490.0313,29.2969 C489.5938,29.2969 489.4688,29.3125 489.3125,29.4219 C489.0625,29.5781 488.9063,29.8594 488.9063,30.1563 C488.9063,30.4063 489.0469,30.6719 489.2656,30.8281 C489.4219,30.9531 489.625,31 490.0313,31 L495.1719,31 C495.9219,31 496.2813,30.7188 496.2813,30.1563 C496.2813,29.875 496.1719,29.625 495.9375,29.4531 C495.7656,29.3281 495.625,29.2969 495.1719,29.2969 L493.4531,29.2969 L493.4531,22.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="64" x="506.5" y="30.8467">Producer</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="93" x="578.5" y="7"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="91" x="579.5" y="19.1387">EncodedImage</text><line style="stroke:#181818;stroke-width:0.5;" x1="478.5" x2="667.5" y1="42" y2="42"/><line style="stroke:#181818;stroke-width:0.5;" x1="478.5" x2="667.5" y1="50" y2="50"/></g><!--class EncodedMemoryCacheProducer--><g id="elem_EncodedMemoryCacheProducer"><rect fill="#F1F1F1" height="48" id="EncodedMemoryCacheProducer" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="260" x="182" y="10"/><ellipse cx="197" cy="26" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M199.3438,21.6719 C198.4063,21.2344 197.8125,21.0938 196.9375,21.0938 C194.3125,21.0938 192.3125,23.1719 192.3125,25.8906 L192.3125,27.0156 C192.3125,29.5938 194.4219,31.4844 197.3125,31.4844 C198.5313,31.4844 199.6875,31.1875 200.4375,30.6406 C201.0156,30.2344 201.3438,29.7813 201.3438,29.3906 C201.3438,28.9375 200.9531,28.5469 200.4844,28.5469 C200.2656,28.5469 200.0625,28.625 199.875,28.8125 C199.4219,29.2969 199.4219,29.2969 199.2344,29.3906 C198.8125,29.6563 198.125,29.7813 197.3594,29.7813 C195.3125,29.7813 194.0156,28.6875 194.0156,26.9844 L194.0156,25.8906 C194.0156,24.1094 195.2656,22.7969 197,22.7969 C197.5781,22.7969 198.1875,22.9531 198.6563,23.2031 C199.1406,23.4844 199.3125,23.7031 199.4063,24.1094 C199.4688,24.5156 199.5,24.6406 199.6406,24.7656 C199.7813,24.9063 200.0156,25.0156 200.2344,25.0156 C200.5,25.0156 200.7656,24.875 200.9375,24.6563 C201.0469,24.5 201.0781,24.3125 201.0781,23.8906 L201.0781,22.4688 C201.0781,22.0313 201.0625,21.9063 200.9688,21.75 C200.8125,21.4844 200.5313,21.3438 200.2344,21.3438 C199.9375,21.3438 199.7344,21.4375 199.5156,21.75 L199.3438,21.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="228" x="211" y="30.8467">EncodedMemoryCacheProducer</text><line style="stroke:#181818;stroke-width:0.5;" x1="183" x2="441" y1="42" y2="42"/><line style="stroke:#181818;stroke-width:0.5;" x1="183" x2="441" y1="50" y2="50"/></g><g id="elem_GMN7"><path d="M703.5,21.5 L703.5,30 L668.625,34 L703.5,38 L703.5,46.6328 A0,0 0 0 0 703.5,46.6328 L802.5,46.6328 A0,0 0 0 0 802.5,46.6328 L802.5,31.5 L792.5,21.5 L703.5,21.5 A0,0 0 0 0 703.5,21.5 " fill="#FEFFDD" style="stroke:#181818;stroke-width:0.5;"/><path d="M792.5,21.5 L792.5,31.5 L802.5,31.5 L792.5,21.5 " fill="#FEFFDD" style="stroke:#181818;stroke-width:0.5;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="78" x="709.5" y="38.5669">&#19979;&#19968;&#32423;&#29983;&#20135;&#32773;</text></g><!--class CountingMemoryCache--><g id="elem_CountingMemoryCache"><rect codeLine="8" fill="#F1F1F1" height="48" id="CountingMemoryCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="372" x="7" y="226"/><ellipse cx="22" cy="242" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M24.3438,237.6719 C23.4063,237.2344 22.8125,237.0938 21.9375,237.0938 C19.3125,237.0938 17.3125,239.1719 17.3125,241.8906 L17.3125,243.0156 C17.3125,245.5938 19.4219,247.4844 22.3125,247.4844 C23.5313,247.4844 24.6875,247.1875 25.4375,246.6406 C26.0156,246.2344 26.3438,245.7813 26.3438,245.3906 C26.3438,244.9375 25.9531,244.5469 25.4844,244.5469 C25.2656,244.5469 25.0625,244.625 24.875,244.8125 C24.4219,245.2969 24.4219,245.2969 24.2344,245.3906 C23.8125,245.6563 23.125,245.7813 22.3594,245.7813 C20.3125,245.7813 19.0156,244.6875 19.0156,242.9844 L19.0156,241.8906 C19.0156,240.1094 20.2656,238.7969 22,238.7969 C22.5781,238.7969 23.1875,238.9531 23.6563,239.2031 C24.1406,239.4844 24.3125,239.7031 24.4063,240.1094 C24.4688,240.5156 24.5,240.6406 24.6406,240.7656 C24.7813,240.9063 25.0156,241.0156 25.2344,241.0156 C25.5,241.0156 25.7656,240.875 25.9375,240.6563 C26.0469,240.5 26.0781,240.3125 26.0781,239.8906 L26.0781,238.4688 C26.0781,238.0313 26.0625,237.9063 25.9688,237.75 C25.8125,237.4844 25.5313,237.3438 25.2344,237.3438 C24.9375,237.3438 24.7344,237.4375 24.5156,237.75 L24.3438,237.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="167" x="36" y="246.8467">CountingMemoryCache</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="171" x="211" y="223"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="169" x="212" y="235.1387">CacheKey, PooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="378" y1="258" y2="258"/><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="378" y1="266" y2="266"/></g><!--class LruCountingMemoryCache--><g id="elem_LruCountingMemoryCache"><rect codeLine="9" fill="#F1F1F1" height="48" id="LruCountingMemoryCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="394" x="186" y="334"/><ellipse cx="201" cy="350" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M203.3438,345.6719 C202.4063,345.2344 201.8125,345.0938 200.9375,345.0938 C198.3125,345.0938 196.3125,347.1719 196.3125,349.8906 L196.3125,351.0156 C196.3125,353.5938 198.4219,355.4844 201.3125,355.4844 C202.5313,355.4844 203.6875,355.1875 204.4375,354.6406 C205.0156,354.2344 205.3438,353.7813 205.3438,353.3906 C205.3438,352.9375 204.9531,352.5469 204.4844,352.5469 C204.2656,352.5469 204.0625,352.625 203.875,352.8125 C203.4219,353.2969 203.4219,353.2969 203.2344,353.3906 C202.8125,353.6563 202.125,353.7813 201.3594,353.7813 C199.3125,353.7813 198.0156,352.6875 198.0156,350.9844 L198.0156,349.8906 C198.0156,348.1094 199.2656,346.7969 201,346.7969 C201.5781,346.7969 202.1875,346.9531 202.6563,347.2031 C203.1406,347.4844 203.3125,347.7031 203.4063,348.1094 C203.4688,348.5156 203.5,348.6406 203.6406,348.7656 C203.7813,348.9063 204.0156,349.0156 204.2344,349.0156 C204.5,349.0156 204.7656,348.875 204.9375,348.6563 C205.0469,348.5 205.0781,348.3125 205.0781,347.8906 L205.0781,346.4688 C205.0781,346.0313 205.0625,345.9063 204.9688,345.75 C204.8125,345.4844 204.5313,345.3438 204.2344,345.3438 C203.9375,345.3438 203.7344,345.4375 203.5156,345.75 L203.3438,345.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="189" x="215" y="354.8467">LruCountingMemoryCache</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="171" x="412" y="331"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="169" x="413" y="343.1387">CacheKey, PooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="187" x2="579" y1="366" y2="366"/><line style="stroke:#181818;stroke-width:0.5;" x1="187" x2="579" y1="374" y2="374"/></g><!--class Entry--><g id="elem_Entry"><rect codeLine="13" fill="#F1F1F1" height="48" id="Entry" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="416" x="534" y="226"/><ellipse cx="549" cy="242" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M551.3438,237.6719 C550.4063,237.2344 549.8125,237.0938 548.9375,237.0938 C546.3125,237.0938 544.3125,239.1719 544.3125,241.8906 L544.3125,243.0156 C544.3125,245.5938 546.4219,247.4844 549.3125,247.4844 C550.5313,247.4844 551.6875,247.1875 552.4375,246.6406 C553.0156,246.2344 553.3438,245.7813 553.3438,245.3906 C553.3438,244.9375 552.9531,244.5469 552.4844,244.5469 C552.2656,244.5469 552.0625,244.625 551.875,244.8125 C551.4219,245.2969 551.4219,245.2969 551.2344,245.3906 C550.8125,245.6563 550.125,245.7813 549.3594,245.7813 C547.3125,245.7813 546.0156,244.6875 546.0156,242.9844 L546.0156,241.8906 C546.0156,240.1094 547.2656,238.7969 549,238.7969 C549.5781,238.7969 550.1875,238.9531 550.6563,239.2031 C551.1406,239.4844 551.3125,239.7031 551.4063,240.1094 C551.4688,240.5156 551.5,240.6406 551.6406,240.7656 C551.7813,240.9063 552.0156,241.0156 552.2344,241.0156 C552.5,241.0156 552.7656,240.875 552.9375,240.6563 C553.0469,240.5 553.0781,240.3125 553.0781,239.8906 L553.0781,238.4688 C553.0781,238.0313 553.0625,237.9063 552.9688,237.75 C552.8125,237.4844 552.5313,237.3438 552.2344,237.3438 C551.9375,237.3438 551.7344,237.4375 551.5156,237.75 L551.3438,237.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="211" x="563" y="246.8467">CountingMemoryCache.Entry</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="171" x="782" y="223"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="169" x="783" y="235.1387">CacheKey, PooledByteBuffer</text><line style="stroke:#181818;stroke-width:0.5;" x1="535" x2="949" y1="258" y2="258"/><line style="stroke:#181818;stroke-width:0.5;" x1="535" x2="949" y1="266" y2="266"/></g><!--class CountingLruMap--><g id="elem_CountingLruMap"><rect codeLine="14" fill="#F1F1F1" height="48" id="CountingLruMap" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="253" x="615.5" y="334"/><ellipse cx="630.5" cy="350" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M632.8438,345.6719 C631.9063,345.2344 631.3125,345.0938 630.4375,345.0938 C627.8125,345.0938 625.8125,347.1719 625.8125,349.8906 L625.8125,351.0156 C625.8125,353.5938 627.9219,355.4844 630.8125,355.4844 C632.0313,355.4844 633.1875,355.1875 633.9375,354.6406 C634.5156,354.2344 634.8438,353.7813 634.8438,353.3906 C634.8438,352.9375 634.4531,352.5469 633.9844,352.5469 C633.7656,352.5469 633.5625,352.625 633.375,352.8125 C632.9219,353.2969 632.9219,353.2969 632.7344,353.3906 C632.3125,353.6563 631.625,353.7813 630.8594,353.7813 C628.8125,353.7813 627.5156,352.6875 627.5156,350.9844 L627.5156,349.8906 C627.5156,348.1094 628.7656,346.7969 630.5,346.7969 C631.0781,346.7969 631.6875,346.9531 632.1563,347.2031 C632.6406,347.4844 632.8125,347.7031 632.9063,348.1094 C632.9688,348.5156 633,348.6406 633.1406,348.7656 C633.2813,348.9063 633.5156,349.0156 633.7344,349.0156 C634,349.0156 634.2656,348.875 634.4375,348.6563 C634.5469,348.5 634.5781,348.3125 634.5781,347.8906 L634.5781,346.4688 C634.5781,346.0313 634.5625,345.9063 634.4688,345.75 C634.3125,345.4844 634.0313,345.3438 633.7344,345.3438 C633.4375,345.3438 633.2344,345.4375 633.0156,345.75 L632.8438,345.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="117" x="644.5" y="354.8467">CountingLruMap</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="102" x="769.5" y="331"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="100" x="770.5" y="343.1387">CacheKey, Entry</text><line style="stroke:#181818;stroke-width:0.5;" x1="616.5" x2="867.5" y1="366" y2="366"/><line style="stroke:#181818;stroke-width:0.5;" x1="616.5" x2="867.5" y1="374" y2="374"/></g><!--reverse link EncodedMemoryCacheProducer to MemoryCache--><g id="link_EncodedMemoryCacheProducer_MemoryCache"><path codeLine="3" d="M312,70 C312,87.658 312,99.941 312,117.678 " fill="none" id="EncodedMemoryCacheProducer-backto-MemoryCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="312,58,308,64,312,70,316,64,312,58" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link EncodedMemoryCacheProducer to Producer--><g id="link_EncodedMemoryCacheProducer_Producer"><path codeLine="4" d="M454.245,34 C465.993,34 465.74,34 477.488,34 " fill="none" id="EncodedMemoryCacheProducer-backto-Producer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="442.245,34,448.245,38,454.245,34,448.245,30,442.245,34" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CountingMemoryCache to LruCountingMemoryCache--><g id="link_CountingMemoryCache_LruCountingMemoryCache"><path codeLine="10" d="M249.9461,282.7699 C281.7061,300.4892 309.704,316.1083 341.526,333.8617 " fill="none" id="CountingMemoryCache-backto-LruCountingMemoryCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="234.227,274,247.0228,288.0096,252.8694,277.5302,234.227,274" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link MemoryCache to LruCountingMemoryCache--><g id="link_MemoryCache_LruCountingMemoryCache"><path codeLine="11" d="M360.4993,177.5464 C378.9703,192.2434 385.885,201.786 396,226 C410.8,261.429 400.576,306.7745 391.799,333.763 " fill="none" id="MemoryCache-backto-LruCountingMemoryCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="346.414,166.339,356.7635,182.2415,364.2351,172.8513,346.414,166.339" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link MemoryCache to CountingMemoryCache--><g id="link_MemoryCache_CountingMemoryCache"><path codeLine="12" d="M272.738,177.9724 C252.914,195.6304 239.095,207.941 219.182,225.678 " fill="none" id="MemoryCache-backto-CountingMemoryCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="286.179,166,268.7472,173.4921,276.7288,182.4528,286.179,166" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link LruCountingMemoryCache to CountingLruMap--><g id="link_LruCountingMemoryCache_CountingLruMap"><path codeLine="15" d="M592.029,358 C603.84,358 603.65,358 615.46,358 " fill="none" id="LruCountingMemoryCache-backto-CountingLruMap" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="580.029,358,586.029,362,592.029,358,586.029,354,580.029,358" style="stroke:#181818;stroke-width:1.0;"/></g><!--link Entry to CountingLruMap--><g id="link_Entry_CountingLruMap"><path codeLine="16" d="M742,274 C742,291.6584 742,303.9408 742,321.6784 " fill="none" id="Entry-to-CountingLruMap" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="742,333.6784,746,327.6784,742,321.6784,738,327.6784,742,333.6784" style="stroke:#181818;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="8" x="732.975" y="294.1558">n</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="8" x="733.025" y="323.005">1</text></g><!--SRC=[dP6_2i8m4CRtFCMHKQpWNZfK74GBla98hhMWYQJ9K71mSN9rT_GLnESfrCUmjlwf4aHT0fVylY_VtQNIe8uPHuXmeNG-O7o6VdsECU_2LAavYZ0t6DeuHXsGzA6OQYKiH-qF9LS2nMZ14Wp8hMhvtK7eU5xxdy_emvz8PH1qcimCgFXvNHotnN5TdWxbRb-S3kVrXg0KSAK9dxCiWu6oqgGo-RQtHZNHzbUXWmT_LNNhzY9_SoweIKqTJxsXD3h_b9m2ow2ctaPM1OhOiYMjeO2uWrxNzQeahoNGFgqWk_I0IjgONG00]--></g></svg>

<p>EncodedMemoryCacheProducer执行时，会首先从MemoryCache读取缓存在内存中的图片，如果有缓存，则将缓存的图片传递给上一级生产者，不再执行下一级生产者。</p>
<?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="445px" preserveAspectRatio="none" style="width:229px;height:445px;background:#FFFFFF;" version="1.1" viewBox="0 0 229 445" width="229px" zoomAndPan="magnify"><defs/><g><ellipse cx="111" cy="20" fill="#222222" rx="10" ry="10" style="stroke:#222222;stroke-width:1.0;"/><rect fill="#F1F1F1" height="33.9688" rx="12.5" ry="12.5" style="stroke:#181818;stroke-width:0.5;" width="200" x="11" y="50"/><text fill="#000000" font-family="sans-serif" font-size="12" lengthAdjust="spacing" textLength="180" x="21" y="71.1387">&#26681;&#25454;CacheKey&#20174;&#32531;&#23384;&#20013;&#33719;&#21462;&#22270;&#29255;</text><rect fill="#F1F1F1" height="33.9688" rx="12.5" ry="12.5" style="stroke:#181818;stroke-width:0.5;" width="116" x="53" y="152.3711"/><text fill="#000000" font-family="sans-serif" font-size="12" lengthAdjust="spacing" textLength="96" x="63" y="173.5098">&#25191;&#34892;&#19979;&#19968;&#32423;&#29983;&#20135;&#32773;</text><rect fill="#F1F1F1" height="33.9688" rx="12.5" ry="12.5" style="stroke:#181818;stroke-width:0.5;" width="164" x="29" y="206.3398"/><text fill="#000000" font-family="sans-serif" font-size="12" lengthAdjust="spacing" textLength="144" x="39" y="227.4785">&#25910;&#21040;&#19979;&#32423;&#29983;&#20135;&#32773;&#36820;&#22238;&#30340;&#22270;&#29255;</text><rect fill="#F1F1F1" height="33.9688" rx="12.5" ry="12.5" style="stroke:#181818;stroke-width:0.5;" width="68" x="77" y="260.3086"/><text fill="#000000" font-family="sans-serif" font-size="12" lengthAdjust="spacing" textLength="48" x="87" y="281.4473">&#32531;&#23384;&#22270;&#29255;</text><polygon fill="#F1F1F1" points="75,103.9688,147,103.9688,159,115.9688,147,127.9688,75,127.9688,63,115.9688,75,103.9688" style="stroke:#181818;stroke-width:0.5;"/><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacing" textLength="33" x="115" y="138.1792">&#19981;&#23384;&#22312;</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacing" textLength="72" x="75" y="119.7769">&#32531;&#23384;&#22270;&#29255;&#23384;&#22312;?</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacing" textLength="22" x="159" y="113.3745">&#23384;&#22312;</text><polygon fill="#F1F1F1" points="111,314.2773,123,326.2773,111,338.2773,99,326.2773,111,314.2773" style="stroke:#181818;stroke-width:0.5;"/><rect fill="#F1F1F1" height="33.9688" rx="12.5" ry="12.5" style="stroke:#181818;stroke-width:0.5;" width="152" x="35" y="358.2773"/><text fill="#000000" font-family="sans-serif" font-size="12" lengthAdjust="spacing" textLength="132" x="45" y="379.416">&#36820;&#22238;&#22270;&#29255;&#32473;&#19978;&#19968;&#32423;&#29983;&#20135;&#32773;</text><ellipse cx="111" cy="423.2461" fill="none" rx="11" ry="11" style="stroke:#222222;stroke-width:1.0;"/><ellipse cx="111" cy="423.2461" fill="#222222" rx="6" ry="6" style="stroke:#222222;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="111" x2="111" y1="30" y2="50"/><polygon fill="#181818" points="107,40,111,50,115,40,111,44" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="111" x2="111" y1="186.3398" y2="206.3398"/><polygon fill="#181818" points="107,196.3398,111,206.3398,115,196.3398,111,200.3398" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="111" x2="111" y1="240.3086" y2="260.3086"/><polygon fill="#181818" points="107,250.3086,111,260.3086,115,250.3086,111,254.3086" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="111" x2="111" y1="127.9688" y2="152.3711"/><polygon fill="#181818" points="107,142.3711,111,152.3711,115,142.3711,111,146.3711" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="159" x2="203" y1="115.9688" y2="115.9688"/><polygon fill="#181818" points="199,213.3242,203,223.3242,207,213.3242,203,217.3242" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="203" x2="203" y1="115.9688" y2="326.2773"/><line style="stroke:#181818;stroke-width:1.0;" x1="203" x2="123" y1="326.2773" y2="326.2773"/><polygon fill="#181818" points="133,322.2773,123,326.2773,133,330.2773,129,326.2773" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="111" x2="111" y1="294.2773" y2="314.2773"/><polygon fill="#181818" points="107,304.2773,111,314.2773,115,304.2773,111,308.2773" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="111" x2="111" y1="83.9688" y2="103.9688"/><polygon fill="#181818" points="107,93.9688,111,103.9688,115,93.9688,111,97.9688" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="111" x2="111" y1="338.2773" y2="358.2773"/><polygon fill="#181818" points="107,348.2773,111,358.2773,115,348.2773,111,352.2773" style="stroke:#181818;stroke-width:1.0;"/><line style="stroke:#181818;stroke-width:1.0;" x1="111" x2="111" y1="392.2461" y2="412.2461"/><polygon fill="#181818" points="107,402.2461,111,412.2461,115,402.2461,111,406.2461" style="stroke:#181818;stroke-width:1.0;"/><!--SRC=[Aov9B2hXidgsOEUptdNEYSaPgTwfbKzszptVC_dfsXbFTgnzqRVzQV-qfxFtFUzij-RAJ5FGW4X1H42CEIliDHLACbBpD9xiw8K8Q78fA5Wzwrp-Oc7FantTJtOqFD-r_FcK-KzsBN_Hq6eDbfooxMd71g0aiioB_LEUpfxtV5OBp3gWGcJRhBbISufJ5JHWbgJcfMIcSLb1j46KFDyzyycEBWmRYqlo2m00]--></g></svg>

<p>加入缓存或者获取缓存等操作，都会触发缓存的清理，清理时如果超过了最大数量或者最大存储空间，都会进行清理，被清理掉的都是不被使用的图片，而且时最老的优先被清理。</p>
<h3 id="DecodeProducer"><a href="#DecodeProducer" class="headerlink" title="DecodeProducer"></a>DecodeProducer</h3><?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="281px" preserveAspectRatio="none" style="width:452px;height:281px;background:#FFFFFF;" version="1.1" viewBox="0 0 452 281" width="452px" zoomAndPan="magnify"><defs/><g><!--class Producer--><g id="elem_Producer"><rect codeLine="1" fill="#F1F1F1" height="48" id="Producer" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="330" x="80.5" y="10"/><ellipse cx="95.5" cy="26" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M96.4531,22.7813 L98.1719,22.7813 C98.5625,22.7813 98.75,22.75 98.875,22.6719 C99.1406,22.5156 99.2813,22.2344 99.2813,21.9375 C99.2813,21.6719 99.1719,21.4063 98.9375,21.2344 C98.7656,21.125 98.625,21.0938 98.1719,21.0938 L93.0313,21.0938 C92.5938,21.0938 92.4688,21.1094 92.3125,21.2031 C92.0625,21.3594 91.9063,21.6563 91.9063,21.9375 C91.9063,22.2188 92.0469,22.4688 92.2656,22.6406 C92.4219,22.75 92.6094,22.7813 93.0313,22.7813 L94.75,22.7813 L94.75,29.2969 L93.0313,29.2969 C92.5938,29.2969 92.4688,29.3125 92.3125,29.4219 C92.0625,29.5781 91.9063,29.8594 91.9063,30.1563 C91.9063,30.4063 92.0469,30.6719 92.2656,30.8281 C92.4219,30.9531 92.625,31 93.0313,31 L98.1719,31 C98.9219,31 99.2813,30.7188 99.2813,30.1563 C99.2813,29.875 99.1719,29.625 98.9375,29.4531 C98.7656,29.3281 98.625,29.2969 98.1719,29.2969 L96.4531,29.2969 L96.4531,22.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="64" x="109.5" y="30.8467">Producer</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="232" x="181.5" y="7"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="230" x="182.5" y="19.1387">CloseableReference&lt;CloseableImage&gt;</text><line style="stroke:#181818;stroke-width:0.5;" x1="81.5" x2="409.5" y1="42" y2="42"/><line style="stroke:#181818;stroke-width:0.5;" x1="81.5" x2="409.5" y1="50" y2="50"/></g><!--class DecodeProducer--><g id="elem_DecodeProducer"><rect fill="#F1F1F1" height="48" id="DecodeProducer" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="151" x="170" y="118"/><ellipse cx="185" cy="134" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M187.3438,129.6719 C186.4063,129.2344 185.8125,129.0938 184.9375,129.0938 C182.3125,129.0938 180.3125,131.1719 180.3125,133.8906 L180.3125,135.0156 C180.3125,137.5938 182.4219,139.4844 185.3125,139.4844 C186.5313,139.4844 187.6875,139.1875 188.4375,138.6406 C189.0156,138.2344 189.3438,137.7813 189.3438,137.3906 C189.3438,136.9375 188.9531,136.5469 188.4844,136.5469 C188.2656,136.5469 188.0625,136.625 187.875,136.8125 C187.4219,137.2969 187.4219,137.2969 187.2344,137.3906 C186.8125,137.6563 186.125,137.7813 185.3594,137.7813 C183.3125,137.7813 182.0156,136.6875 182.0156,134.9844 L182.0156,133.8906 C182.0156,132.1094 183.2656,130.7969 185,130.7969 C185.5781,130.7969 186.1875,130.9531 186.6563,131.2031 C187.1406,131.4844 187.3125,131.7031 187.4063,132.1094 C187.4688,132.5156 187.5,132.6406 187.6406,132.7656 C187.7813,132.9063 188.0156,133.0156 188.2344,133.0156 C188.5,133.0156 188.7656,132.875 188.9375,132.6563 C189.0469,132.5 189.0781,132.3125 189.0781,131.8906 L189.0781,130.4688 C189.0781,130.0313 189.0625,129.9063 188.9688,129.75 C188.8125,129.4844 188.5313,129.3438 188.2344,129.3438 C187.9375,129.3438 187.7344,129.4375 187.5156,129.75 L187.3438,129.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="119" x="199" y="138.8467">DecodeProducer</text><line style="stroke:#181818;stroke-width:0.5;" x1="171" x2="320" y1="150" y2="150"/><line style="stroke:#181818;stroke-width:0.5;" x1="171" x2="320" y1="158" y2="158"/></g><!--class ByteArrayPool--><g id="elem_ByteArrayPool"><rect fill="#F1F1F1" height="48" id="ByteArrayPool" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="135" x="7" y="226"/><ellipse cx="22" cy="242" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M24.3438,237.6719 C23.4063,237.2344 22.8125,237.0938 21.9375,237.0938 C19.3125,237.0938 17.3125,239.1719 17.3125,241.8906 L17.3125,243.0156 C17.3125,245.5938 19.4219,247.4844 22.3125,247.4844 C23.5313,247.4844 24.6875,247.1875 25.4375,246.6406 C26.0156,246.2344 26.3438,245.7813 26.3438,245.3906 C26.3438,244.9375 25.9531,244.5469 25.4844,244.5469 C25.2656,244.5469 25.0625,244.625 24.875,244.8125 C24.4219,245.2969 24.4219,245.2969 24.2344,245.3906 C23.8125,245.6563 23.125,245.7813 22.3594,245.7813 C20.3125,245.7813 19.0156,244.6875 19.0156,242.9844 L19.0156,241.8906 C19.0156,240.1094 20.2656,238.7969 22,238.7969 C22.5781,238.7969 23.1875,238.9531 23.6563,239.2031 C24.1406,239.4844 24.3125,239.7031 24.4063,240.1094 C24.4688,240.5156 24.5,240.6406 24.6406,240.7656 C24.7813,240.9063 25.0156,241.0156 25.2344,241.0156 C25.5,241.0156 25.7656,240.875 25.9375,240.6563 C26.0469,240.5 26.0781,240.3125 26.0781,239.8906 L26.0781,238.4688 C26.0781,238.0313 26.0625,237.9063 25.9688,237.75 C25.8125,237.4844 25.5313,237.3438 25.2344,237.3438 C24.9375,237.3438 24.7344,237.4375 24.5156,237.75 L24.3438,237.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="103" x="36" y="246.8467">ByteArrayPool</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="141" y1="258" y2="258"/><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="141" y1="266" y2="266"/></g><!--class ImageDecoder--><g id="elem_ImageDecoder"><rect fill="#F1F1F1" height="48" id="ImageDecoder" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="137" x="177" y="226"/><ellipse cx="192" cy="242" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M194.3438,237.6719 C193.4063,237.2344 192.8125,237.0938 191.9375,237.0938 C189.3125,237.0938 187.3125,239.1719 187.3125,241.8906 L187.3125,243.0156 C187.3125,245.5938 189.4219,247.4844 192.3125,247.4844 C193.5313,247.4844 194.6875,247.1875 195.4375,246.6406 C196.0156,246.2344 196.3438,245.7813 196.3438,245.3906 C196.3438,244.9375 195.9531,244.5469 195.4844,244.5469 C195.2656,244.5469 195.0625,244.625 194.875,244.8125 C194.4219,245.2969 194.4219,245.2969 194.2344,245.3906 C193.8125,245.6563 193.125,245.7813 192.3594,245.7813 C190.3125,245.7813 189.0156,244.6875 189.0156,242.9844 L189.0156,241.8906 C189.0156,240.1094 190.2656,238.7969 192,238.7969 C192.5781,238.7969 193.1875,238.9531 193.6563,239.2031 C194.1406,239.4844 194.3125,239.7031 194.4063,240.1094 C194.4688,240.5156 194.5,240.6406 194.6406,240.7656 C194.7813,240.9063 195.0156,241.0156 195.2344,241.0156 C195.5,241.0156 195.7656,240.875 195.9375,240.6563 C196.0469,240.5 196.0781,240.3125 196.0781,239.8906 L196.0781,238.4688 C196.0781,238.0313 196.0625,237.9063 195.9688,237.75 C195.8125,237.4844 195.5313,237.3438 195.2344,237.3438 C194.9375,237.3438 194.7344,237.4375 194.5156,237.75 L194.3438,237.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="105" x="206" y="246.8467">ImageDecoder</text><line style="stroke:#181818;stroke-width:0.5;" x1="178" x2="313" y1="258" y2="258"/><line style="stroke:#181818;stroke-width:0.5;" x1="178" x2="313" y1="266" y2="266"/></g><!--class Executor--><g id="elem_Executor"><rect fill="#F1F1F1" height="48" id="Executor" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="96" x="349.5" y="226"/><ellipse cx="364.5" cy="242" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M366.8438,237.6719 C365.9063,237.2344 365.3125,237.0938 364.4375,237.0938 C361.8125,237.0938 359.8125,239.1719 359.8125,241.8906 L359.8125,243.0156 C359.8125,245.5938 361.9219,247.4844 364.8125,247.4844 C366.0313,247.4844 367.1875,247.1875 367.9375,246.6406 C368.5156,246.2344 368.8438,245.7813 368.8438,245.3906 C368.8438,244.9375 368.4531,244.5469 367.9844,244.5469 C367.7656,244.5469 367.5625,244.625 367.375,244.8125 C366.9219,245.2969 366.9219,245.2969 366.7344,245.3906 C366.3125,245.6563 365.625,245.7813 364.8594,245.7813 C362.8125,245.7813 361.5156,244.6875 361.5156,242.9844 L361.5156,241.8906 C361.5156,240.1094 362.7656,238.7969 364.5,238.7969 C365.0781,238.7969 365.6875,238.9531 366.1563,239.2031 C366.6406,239.4844 366.8125,239.7031 366.9063,240.1094 C366.9688,240.5156 367,240.6406 367.1406,240.7656 C367.2813,240.9063 367.5156,241.0156 367.7344,241.0156 C368,241.0156 368.2656,240.875 368.4375,240.6563 C368.5469,240.5 368.5781,240.3125 368.5781,239.8906 L368.5781,238.4688 C368.5781,238.0313 368.5625,237.9063 368.4688,237.75 C368.3125,237.4844 368.0313,237.3438 367.7344,237.3438 C367.4375,237.3438 367.2344,237.4375 367.0156,237.75 L366.8438,237.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="64" x="378.5" y="246.8467">Executor</text><line style="stroke:#181818;stroke-width:0.5;" x1="350.5" x2="444.5" y1="258" y2="258"/><line style="stroke:#181818;stroke-width:0.5;" x1="350.5" x2="444.5" y1="266" y2="266"/></g><!--reverse link Producer to DecodeProducer--><g id="link_Producer_DecodeProducer"><path codeLine="2" d="M245.5,76 C245.5,93.658 245.5,99.941 245.5,117.678 " fill="none" id="Producer-backto-DecodeProducer" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="245.5,58,239.5,76,251.5,76,245.5,58" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DecodeProducer to ByteArrayPool--><g id="link_DecodeProducer_ByteArrayPool"><path codeLine="3" d="M198.1966,172.3224 C169.6116,190.0417 140.467,208.1083 111.827,225.8617 " fill="none" id="DecodeProducer-backto-ByteArrayPool" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="208.396,166,201.1888,165.7614,198.1966,172.3224,205.4038,172.561,208.396,166" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DecodeProducer to ImageDecoder--><g id="link_DecodeProducer_ImageDecoder"><path codeLine="4" d="M245.5,178 C245.5,195.6584 245.5,207.9408 245.5,225.6784 " fill="none" id="DecodeProducer-backto-ImageDecoder" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="245.5,166,241.5,172,245.5,178,249.5,172,245.5,166" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link DecodeProducer to Executor--><g id="link_DecodeProducer_Executor"><path codeLine="5" d="M288.3248,172.8643 C313.7328,190.5836 338.863,208.1083 364.321,225.8617 " fill="none" id="DecodeProducer-backto-Executor" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="278.482,166,281.1153,172.7131,288.3248,172.8643,285.6915,166.1512,278.482,166" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[oymhIIrAIqnELGWeoayfJKujid7EoIzEJKpAIGrAJKijIirBJaK8UUOcfgVQsN7152lOrEZgAhYa9kUdfCB4k52v2bf05KwL9QcEHKM9bG7v-JdO580DXeXZDS2r8ZMvj2I_2000]--></g></svg>

<h3 id="BitmapMemoryCacheProducer"><a href="#BitmapMemoryCacheProducer" class="headerlink" title="BitmapMemoryCacheProducer"></a>BitmapMemoryCacheProducer</h3><?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="402px" preserveAspectRatio="none" style="width:643px;height:402px;background:#FFFFFF;" version="1.1" viewBox="0 0 643 402" width="643px" zoomAndPan="magnify"><defs/><g><!--class MemoryCache--><g id="elem_MemoryCache"><rect codeLine="1" fill="#F1F1F1" height="48" id="MemoryCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="300" x="332" y="123"/><ellipse cx="347" cy="139" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M347.9531,135.7813 L349.6719,135.7813 C350.0625,135.7813 350.25,135.75 350.375,135.6719 C350.6406,135.5156 350.7813,135.2344 350.7813,134.9375 C350.7813,134.6719 350.6719,134.4063 350.4375,134.2344 C350.2656,134.125 350.125,134.0938 349.6719,134.0938 L344.5313,134.0938 C344.0938,134.0938 343.9688,134.1094 343.8125,134.2031 C343.5625,134.3594 343.4063,134.6563 343.4063,134.9375 C343.4063,135.2188 343.5469,135.4688 343.7656,135.6406 C343.9219,135.75 344.1094,135.7813 344.5313,135.7813 L346.25,135.7813 L346.25,142.2969 L344.5313,142.2969 C344.0938,142.2969 343.9688,142.3125 343.8125,142.4219 C343.5625,142.5781 343.4063,142.8594 343.4063,143.1563 C343.4063,143.4063 343.5469,143.6719 343.7656,143.8281 C343.9219,143.9531 344.125,144 344.5313,144 L349.6719,144 C350.4219,144 350.7813,143.7188 350.7813,143.1563 C350.7813,142.875 350.6719,142.625 350.4375,142.4531 C350.2656,142.3281 350.125,142.2969 349.6719,142.2969 L347.9531,142.2969 L347.9531,135.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="103" x="361" y="143.8467">MemoryCache</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="163" x="472" y="120"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="161" x="473" y="132.1387">CacheKey, CloseableImage</text><line style="stroke:#181818;stroke-width:0.5;" x1="333" x2="631" y1="155" y2="155"/><line style="stroke:#181818;stroke-width:0.5;" x1="333" x2="631" y1="163" y2="163"/></g><!--class CountingMemoryCache--><g id="elem_CountingMemoryCache"><rect codeLine="2" fill="#F1F1F1" height="48" id="CountingMemoryCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="364" x="65" y="239"/><ellipse cx="80" cy="255" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M80.9531,251.7813 L82.6719,251.7813 C83.0625,251.7813 83.25,251.75 83.375,251.6719 C83.6406,251.5156 83.7813,251.2344 83.7813,250.9375 C83.7813,250.6719 83.6719,250.4063 83.4375,250.2344 C83.2656,250.125 83.125,250.0938 82.6719,250.0938 L77.5313,250.0938 C77.0938,250.0938 76.9688,250.1094 76.8125,250.2031 C76.5625,250.3594 76.4063,250.6563 76.4063,250.9375 C76.4063,251.2188 76.5469,251.4688 76.7656,251.6406 C76.9219,251.75 77.1094,251.7813 77.5313,251.7813 L79.25,251.7813 L79.25,258.2969 L77.5313,258.2969 C77.0938,258.2969 76.9688,258.3125 76.8125,258.4219 C76.5625,258.5781 76.4063,258.8594 76.4063,259.1563 C76.4063,259.4063 76.5469,259.6719 76.7656,259.8281 C76.9219,259.9531 77.125,260 77.5313,260 L82.6719,260 C83.4219,260 83.7813,259.7188 83.7813,259.1563 C83.7813,258.875 83.6719,258.625 83.4375,258.4531 C83.2656,258.3281 83.125,258.2969 82.6719,258.2969 L80.9531,258.2969 L80.9531,251.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="167" x="94" y="259.8467">CountingMemoryCache</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="163" x="269" y="236"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="161" x="270" y="248.1387">CacheKey, CloseableImage</text><line style="stroke:#181818;stroke-width:0.5;" x1="66" x2="428" y1="271" y2="271"/><line style="stroke:#181818;stroke-width:0.5;" x1="66" x2="428" y1="279" y2="279"/></g><!--class LruCountingMemoryCache--><g id="elem_LruCountingMemoryCache"><rect codeLine="3" fill="#F1F1F1" height="48" id="LruCountingMemoryCache" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="386" x="171" y="347"/><ellipse cx="186" cy="363" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M188.3438,358.6719 C187.4063,358.2344 186.8125,358.0938 185.9375,358.0938 C183.3125,358.0938 181.3125,360.1719 181.3125,362.8906 L181.3125,364.0156 C181.3125,366.5938 183.4219,368.4844 186.3125,368.4844 C187.5313,368.4844 188.6875,368.1875 189.4375,367.6406 C190.0156,367.2344 190.3438,366.7813 190.3438,366.3906 C190.3438,365.9375 189.9531,365.5469 189.4844,365.5469 C189.2656,365.5469 189.0625,365.625 188.875,365.8125 C188.4219,366.2969 188.4219,366.2969 188.2344,366.3906 C187.8125,366.6563 187.125,366.7813 186.3594,366.7813 C184.3125,366.7813 183.0156,365.6875 183.0156,363.9844 L183.0156,362.8906 C183.0156,361.1094 184.2656,359.7969 186,359.7969 C186.5781,359.7969 187.1875,359.9531 187.6563,360.2031 C188.1406,360.4844 188.3125,360.7031 188.4063,361.1094 C188.4688,361.5156 188.5,361.6406 188.6406,361.7656 C188.7813,361.9063 189.0156,362.0156 189.2344,362.0156 C189.5,362.0156 189.7656,361.875 189.9375,361.6563 C190.0469,361.5 190.0781,361.3125 190.0781,360.8906 L190.0781,359.4688 C190.0781,359.0313 190.0625,358.9063 189.9688,358.75 C189.8125,358.4844 189.5313,358.3438 189.2344,358.3438 C188.9375,358.3438 188.7344,358.4375 188.5156,358.75 L188.3438,358.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="189" x="200" y="367.8467">LruCountingMemoryCache</text><rect fill="#FFFFFF" height="15.9688" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:2.0,2.0;" width="163" x="397" y="344"/><text fill="#000000" font-family="sans-serif" font-size="12" font-style="italic" lengthAdjust="spacing" textLength="161" x="398" y="356.1387">CacheKey, CloseableImage</text><line style="stroke:#181818;stroke-width:0.5;" x1="172" x2="556" y1="379" y2="379"/><line style="stroke:#181818;stroke-width:0.5;" x1="172" x2="556" y1="387" y2="387"/></g><!--class BitmapMemoryCacheProducer--><g id="elem_BitmapMemoryCacheProducer"><rect fill="#F1F1F1" height="48" id="BitmapMemoryCacheProducer" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="251" x="356.5" y="7"/><ellipse cx="371.5" cy="23" fill="#ADD1B2" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M373.8438,18.6719 C372.9063,18.2344 372.3125,18.0938 371.4375,18.0938 C368.8125,18.0938 366.8125,20.1719 366.8125,22.8906 L366.8125,24.0156 C366.8125,26.5938 368.9219,28.4844 371.8125,28.4844 C373.0313,28.4844 374.1875,28.1875 374.9375,27.6406 C375.5156,27.2344 375.8438,26.7813 375.8438,26.3906 C375.8438,25.9375 375.4531,25.5469 374.9844,25.5469 C374.7656,25.5469 374.5625,25.625 374.375,25.8125 C373.9219,26.2969 373.9219,26.2969 373.7344,26.3906 C373.3125,26.6563 372.625,26.7813 371.8594,26.7813 C369.8125,26.7813 368.5156,25.6875 368.5156,23.9844 L368.5156,22.8906 C368.5156,21.1094 369.7656,19.7969 371.5,19.7969 C372.0781,19.7969 372.6875,19.9531 373.1563,20.2031 C373.6406,20.4844 373.8125,20.7031 373.9063,21.1094 C373.9688,21.5156 374,21.6406 374.1406,21.7656 C374.2813,21.9063 374.5156,22.0156 374.7344,22.0156 C375,22.0156 375.2656,21.875 375.4375,21.6563 C375.5469,21.5 375.5781,21.3125 375.5781,20.8906 L375.5781,19.4688 C375.5781,19.0313 375.5625,18.9063 375.4688,18.75 C375.3125,18.4844 375.0313,18.3438 374.7344,18.3438 C374.4375,18.3438 374.2344,18.4375 374.0156,18.75 L373.8438,18.6719 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="219" x="385.5" y="27.8467">BitmapMemoryCacheProducer</text><line style="stroke:#181818;stroke-width:0.5;" x1="357.5" x2="606.5" y1="39" y2="39"/><line style="stroke:#181818;stroke-width:0.5;" x1="357.5" x2="606.5" y1="47" y2="47"/></g><!--class MemoryTrimmable--><g id="elem_MemoryTrimmable"><rect codeLine="8" fill="#F1F1F1" height="64.2969" id="MemoryTrimmable" rx="2.5" ry="2.5" style="stroke:#181818;stroke-width:0.5;" width="290" x="7" y="115"/><ellipse cx="79.75" cy="131" fill="#B4A7E5" rx="11" ry="11" style="stroke:#181818;stroke-width:1.0;"/><path d="M80.7031,127.7813 L82.4219,127.7813 C82.8125,127.7813 83,127.75 83.125,127.6719 C83.3906,127.5156 83.5313,127.2344 83.5313,126.9375 C83.5313,126.6719 83.4219,126.4063 83.1875,126.2344 C83.0156,126.125 82.875,126.0938 82.4219,126.0938 L77.2813,126.0938 C76.8438,126.0938 76.7188,126.1094 76.5625,126.2031 C76.3125,126.3594 76.1563,126.6563 76.1563,126.9375 C76.1563,127.2188 76.2969,127.4688 76.5156,127.6406 C76.6719,127.75 76.8594,127.7813 77.2813,127.7813 L79,127.7813 L79,134.2969 L77.2813,134.2969 C76.8438,134.2969 76.7188,134.3125 76.5625,134.4219 C76.3125,134.5781 76.1563,134.8594 76.1563,135.1563 C76.1563,135.4063 76.2969,135.6719 76.5156,135.8281 C76.6719,135.9531 76.875,136 77.2813,136 L82.4219,136 C83.1719,136 83.5313,135.7188 83.5313,135.1563 C83.5313,134.875 83.4219,134.625 83.1875,134.4531 C83.0156,134.3281 82.875,134.2969 82.4219,134.2969 L80.7031,134.2969 L80.7031,127.7813 Z " fill="#000000"/><text fill="#000000" font-family="sans-serif" font-size="14" font-style="italic" lengthAdjust="spacing" textLength="136" x="100.25" y="135.8467">MemoryTrimmable</text><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="296" y1="147" y2="147"/><line style="stroke:#181818;stroke-width:0.5;" x1="8" x2="296" y1="155" y2="155"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="278" x="13" y="171.9951">void trim(MemoryTrimType trimType);</text></g><!--reverse link BitmapMemoryCacheProducer to MemoryCache--><g id="link_BitmapMemoryCacheProducer_MemoryCache"><path codeLine="4" d="M482,67.07 C482,86.848 482,103.196 482,122.965 " fill="none" id="BitmapMemoryCacheProducer-backto-MemoryCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="#181818" points="482,55.07,478,61.07,482,67.07,486,61.07,482,55.07" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link MemoryCache to LruCountingMemoryCache--><g id="link_MemoryCache_LruCountingMemoryCache"><path codeLine="5" d="M477.9205,188.9316 C474.5905,217.7026 468.12,249.771 447,287 C433.727,310.3967 412.074,331.7327 394.213,346.9126 " fill="none" id="MemoryCache-backto-LruCountingMemoryCache" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:7.0,7.0;"/><polygon fill="none" points="479.99,171.051,471.9603,188.2418,483.8807,189.6215,479.99,171.051" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link CountingMemoryCache to LruCountingMemoryCache--><g id="link_CountingMemoryCache_LruCountingMemoryCache"><path codeLine="6" d="M285.7266,299.0854 C305.2176,316.7438 318.68,328.9408 338.258,346.6784 " fill="none" id="CountingMemoryCache-backto-LruCountingMemoryCache" style="stroke:#181818;stroke-width:1.0;stroke-dasharray:7.0,7.0;"/><polygon fill="none" points="272.387,287,281.6981,303.5319,289.755,294.6388,272.387,287" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link MemoryCache to CountingMemoryCache--><g id="link_MemoryCache_CountingMemoryCache"><path codeLine="7" d="M418.2489,178.9262 C377.4779,198.7042 335.236,219.196 294.485,238.965 " fill="none" id="MemoryCache-backto-CountingMemoryCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="434.444,171.07,415.6302,173.5279,420.8677,184.3246,434.444,171.07" style="stroke:#181818;stroke-width:1.0;"/></g><!--reverse link MemoryTrimmable to CountingMemoryCache--><g id="link_MemoryTrimmable_CountingMemoryCache"><path codeLine="11" d="M189.4825,192.9789 C205.1945,211.8329 213.373,221.647 227.704,238.845 " fill="none" id="MemoryTrimmable-backto-CountingMemoryCache" style="stroke:#181818;stroke-width:1.0;"/><polygon fill="none" points="177.959,179.151,184.8732,196.82,194.0918,189.1377,177.959,179.151" style="stroke:#181818;stroke-width:1.0;"/></g><!--SRC=[oymhIIrAIqnELV1DpSqlgdHEJCv8jG6JtgcLEWhEEVd5gOb9EQcUkOdfgNPScN3rplcbUIMPUUd4wKlEIImkLl0fAYLDcrDcIMvY0PBQWABybDBar285BLrTP2Tp8R4LR6hqz73OnOL53AzwL7L0Ix4foaGBnP2YpDnSa3SKghaKWA0iFpD5eGGeg86G3waiI0MBWHYQrborNEXwSLa70000]--></g></svg>

<p>配置参数的默认值：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//imagepipeline/src/main/java/com/facebook/imagepipeline/cache/DefaultBitmapMemoryCacheParamsSupplier.java</span></span><br><span class="line">  <span class="keyword">public</span> MemoryCacheParams <span class="title function_">get</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">MemoryCacheParams</span>(</span><br><span class="line">        getMaxCacheSize(), <span class="comment">//maxCacheSize等于APP最大堆内存的四分之一，代码见后面</span></span><br><span class="line">        MAX_CACHE_ENTRIES, <span class="comment">//maxCacheEntries = 256</span></span><br><span class="line">        MAX_EVICTION_QUEUE_SIZE, <span class="comment">//maxEvictionQueueSize = Integer.MAX_VALUE</span></span><br><span class="line">        MAX_EVICTION_QUEUE_ENTRIES, <span class="comment">//maxEvictionQueueEntries = Integer.MAX_VALUE</span></span><br><span class="line">        MAX_CACHE_ENTRY_SIZE, <span class="comment">//maxCacheEntrySize = Integer.MAX_VALUE</span></span><br><span class="line">        PARAMS_CHECK_INTERVAL_MS); <span class="comment">//paramsCheckIntervalMs = 5 minutes</span></span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">private</span> <span class="type">int</span> <span class="title function_">getMaxCacheSize</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="comment">//mActivityManager.getMemoryClass()是获取的没有设置android:largeHeap属性的APP的最大堆内存；</span></span><br><span class="line">    <span class="comment">//也就是获取系统属性dalvik.vm.heapgrowthlimit的值</span></span><br><span class="line">    <span class="keyword">final</span> <span class="type">int</span> <span class="variable">maxMemory</span> <span class="operator">=</span></span><br><span class="line">        Math.min(mActivityManager.getMemoryClass() * ByteConstants.MB, Integer.MAX_VALUE);</span><br><span class="line">    <span class="keyword">if</span> (maxMemory &lt; <span class="number">32</span> * ByteConstants.MB) &#123;</span><br><span class="line">      <span class="keyword">return</span> <span class="number">4</span> * ByteConstants.MB;</span><br><span class="line">    &#125; <span class="keyword">else</span> <span class="keyword">if</span> (maxMemory &lt; <span class="number">64</span> * ByteConstants.MB) &#123;</span><br><span class="line">      <span class="keyword">return</span> <span class="number">6</span> * ByteConstants.MB;</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">      <span class="keyword">return</span> maxMemory / <span class="number">4</span>; <span class="comment">//app最大堆内存的四分之一</span></span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>



<h4 id="从缓存获取Bitmap"><a href="#从缓存获取Bitmap" class="headerlink" title="从缓存获取Bitmap"></a>从缓存获取Bitmap</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//LruCountingMemoryCache.java</span></span><br><span class="line">  <span class="keyword">public</span> CloseableReference&lt;V&gt; <span class="title function_">get</span><span class="params">(<span class="keyword">final</span> K key)</span> &#123;</span><br><span class="line">    Preconditions.checkNotNull(key);</span><br><span class="line">    Entry&lt;K, V&gt; oldExclusive;</span><br><span class="line">    CloseableReference&lt;V&gt; clientRef = <span class="literal">null</span>;</span><br><span class="line">    <span class="keyword">synchronized</span> (<span class="built_in">this</span>) &#123;</span><br><span class="line">      oldExclusive = mExclusiveEntries.remove(key); <span class="comment">//首先从回收列表移除</span></span><br><span class="line">      Entry&lt;K, V&gt; entry = mCachedEntries.get(key);  <span class="comment">//从LinkedHashMap中获取缓存的Bitmap</span></span><br><span class="line">      <span class="keyword">if</span> (entry != <span class="literal">null</span>) &#123;</span><br><span class="line">        clientRef = newClientReference(entry);</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    maybeNotifyExclusiveEntryRemoval(oldExclusive);</span><br><span class="line">    maybeUpdateCacheParams(); <span class="comment">//查看是否需要更新配置参数，前面已经介绍</span></span><br><span class="line">    maybeEvictEntries();</span><br><span class="line">    <span class="keyword">return</span> clientRef;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="comment">//如果内存超过最大限制，就会开始清理回收列表中存在的Bitmap</span></span><br><span class="line">  <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">maybeEvictEntries</span><span class="params">()</span> &#123;</span><br><span class="line">    ArrayList&lt;Entry&lt;K, V&gt;&gt; oldEntries;</span><br><span class="line">    <span class="keyword">synchronized</span> (<span class="built_in">this</span>) &#123;</span><br><span class="line">      <span class="type">int</span> <span class="variable">maxCount</span> <span class="operator">=</span></span><br><span class="line">          Math.min(</span><br><span class="line">              mMemoryCacheParams.maxEvictionQueueEntries, <span class="comment">//maxEvictionQueueEntries默认是Integer.MAX_VALUE</span></span><br><span class="line">              mMemoryCacheParams.maxCacheEntries - getInUseCount()); <span class="comment">//maxCacheEntries默认是256</span></span><br><span class="line">      <span class="type">int</span> <span class="variable">maxSize</span> <span class="operator">=</span></span><br><span class="line">          Math.min(</span><br><span class="line">              mMemoryCacheParams.maxEvictionQueueSize, <span class="comment">//maxEvictionQueueSize默认值Integer.MAX_VALUE</span></span><br><span class="line">              mMemoryCacheParams.maxCacheSize - getInUseSizeInBytes()); <span class="comment">//maxCacheSize是APP最大堆内存的四分之一</span></span><br><span class="line">      oldEntries = trimExclusivelyOwnedEntries(maxCount, maxSize);</span><br><span class="line">      makeOrphans(oldEntries);</span><br><span class="line">    &#125;</span><br><span class="line">    maybeClose(oldEntries);</span><br><span class="line">    maybeNotifyExclusiveEntryRemoval(oldEntries);</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="type">int</span> <span class="title function_">getInUseCount</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> mCachedEntries.getCount() - mExclusiveEntries.getCount();</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="type">int</span> <span class="title function_">getInUseSizeInBytes</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> mCachedEntries.getSizeInBytes() - mExclusiveEntries.getSizeInBytes();</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="keyword">private</span> <span class="keyword">synchronized</span> ArrayList&lt;Entry&lt;K, V&gt;&gt; <span class="title function_">trimExclusivelyOwnedEntries</span><span class="params">(<span class="type">int</span> count, <span class="type">int</span> size)</span> &#123;</span><br><span class="line">    count = Math.max(count, <span class="number">0</span>);</span><br><span class="line">    size = Math.max(size, <span class="number">0</span>);</span><br><span class="line">    <span class="comment">// fast path without array allocation if no eviction is necessary</span></span><br><span class="line">    <span class="keyword">if</span> (<span class="built_in">this</span>.mExclusiveEntries.getCount() &lt;= count &amp;&amp; mExclusiveEntries.getSizeInBytes() &lt;= size) &#123;</span><br><span class="line">      <span class="keyword">return</span> <span class="literal">null</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    ArrayList&lt;Entry&lt;K, V&gt;&gt; oldEntries = <span class="keyword">new</span> <span class="title class_">ArrayList</span>&lt;&gt;();</span><br><span class="line">    <span class="keyword">while</span> (<span class="built_in">this</span>.mExclusiveEntries.getCount() &gt; count || mExclusiveEntries.getSizeInBytes() &gt; size) &#123;</span><br><span class="line">      <span class="meta">@Nullable</span> <span class="type">K</span> <span class="variable">key</span> <span class="operator">=</span> mExclusiveEntries.getFirstKey();</span><br><span class="line">      <span class="keyword">if</span> (key == <span class="literal">null</span>) &#123;</span><br><span class="line">        <span class="keyword">if</span> (mIgnoreSizeMismatch) &#123;</span><br><span class="line">          mExclusiveEntries.resetSize();</span><br><span class="line">          <span class="keyword">break</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">throw</span> <span class="keyword">new</span> <span class="title class_">IllegalStateException</span>(</span><br><span class="line">            String.format(</span><br><span class="line">                <span class="string">&quot;key is null, but exclusiveEntries count: %d, size: %d&quot;</span>,</span><br><span class="line">                <span class="built_in">this</span>.mExclusiveEntries.getCount(), mExclusiveEntries.getSizeInBytes()));</span><br><span class="line">      &#125;</span><br><span class="line">      mExclusiveEntries.remove(key);</span><br><span class="line">      oldEntries.add(mCachedEntries.remove(key));</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> oldEntries;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<h3 id="BitmapPrepareProducer"><a href="#BitmapPrepareProducer" class="headerlink" title="BitmapPrepareProducer"></a>BitmapPrepareProducer</h3><p>BitmapPrepareProducer只有一个作用，就是调用<code>Bitmap#prepareToDraw()</code>。prepareToDraw接口会构建一个用于绘制的缓存。从Android7.0开始，这个接口会在RenderThread线程上启动GPU的异步上传。开启硬件加速后，Bitmap必须上传到GPU才能被渲染。Bitmap第一次绘制时会默认就执行GPU上传动作，但是这个有几毫秒的耗时，图片越大耗时越高。通过调用prepareToDraw可以提前完成上传GPU的动作，这样可以节省第一帧的显示时间。</p>
<hr>
<h2 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h2><p><a target="_blank" rel="noopener external nofollow noreferrer" href="https://developer.android.google.cn/topic/performance/graphics/manage-memory">Managing Bitmap Memory</a><br><a target="_blank" rel="noopener external nofollow noreferrer" href="https://www.cnblogs.com/wytiger/p/5690039.html">Fresco内存机制(Ashmem匿名共享内存）</a><br><a target="_blank" rel="noopener external nofollow noreferrer" href="https://www.kaelli.com/9.html">Android网络加载图片库对比：Fresco、Glide、Picasso</a><br><a target="_blank" rel="noopener external nofollow noreferrer" href="https://www.jianshu.com/p/6f042f9e47a8">Android | Bitmap的Java对象GC之后，对应的native内存会回收吗？</a><br><a target="_blank" rel="noopener external nofollow noreferrer" href="https://blog.csdn.net/niuba123456/article/details/86548437">Android图片缓存框架 - Fresco设置和清除缓存(十一)</a></p>
<!-- 生产者序列图按照执行序列 -->
<!-- ```plantuml
@startuml
skinparam componentStyle rectangle
component [DelayProducer] #back:white;line.dotted
[DelayProducer] -> [BitmapPrepareProducer]
component [PostprocessedBitmapMemoryCacheProducer] #back:white;line.dotted
[BitmapPrepareProducer] -> [PostprocessedBitmapMemoryCacheProducer]
[PostprocessedBitmapMemoryCacheProducer] -> [PostprocessorProducer]
component [PostprocessorProducer] #back:white;line.dotted
[PostprocessorProducer] -\-> [BitmapProbeProducer]
component [BitmapProbeProducer] #back:white;line.dotted
[BitmapProbeProducer] -left-> [BitmapMemoryCacheGetProducer]
[BitmapMemoryCacheGetProducer] -left-> [ThreadHandoffProducer]
[ThreadHandoffProducer] -left-> [BitmapMemoryCacheKeyMultiplexProducer]
[BitmapMemoryCacheKeyMultiplexProducer] -\-> [BitmapMemoryCacheProducer]
[BitmapMemoryCacheProducer] -> [DecodeProducer]
[DecodeProducer] -> [ResizeAndRotateProducer]
[ResizeAndRotateProducer] -> [AddImageTransformMetaDataProducer]
[AddImageTransformMetaDataProducer] -\-> [EncodedCacheKeyMultiplexProducer]
component [EncodedProbeProducer] #back:white;line.dotted
[EncodedCacheKeyMultiplexProducer] -left-> [EncodedProbeProducer]
[EncodedProbeProducer] -left-> [EncodedMemoryCacheProducer]
[EncodedMemoryCacheProducer] -left-> [DiskCacheReadProducer]
[DiskCacheReadProducer] -\-> [DiskCacheWriteProducer]
[DiskCacheWriteProducer] -> [PartialDiskCacheProducer]
component [PartialDiskCacheProducer] #back:white;line.dotted
[PartialDiskCacheProducer] -> [WebpTranscodeProducer]
component [WebpTranscodeProducer] #back:white;line.dotted
[WebpTranscodeProducer] -> [NetworkFetchProducer]
@enduml
``` -->
    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Android/" rel="tag"># Android</a>
              <a href="/tags/Fresco/" rel="tag"># Fresco</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/posts/fd3db9c4.html" rel="prev" title="Java CAS详解">
                  <i class="fa fa-angle-left"></i> Java CAS详解
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/posts/32780962.html" rel="next" title="PlantUML样式指南">
                  PlantUML样式指南 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 
    <span itemprop="copyrightYear">2024</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">Jason</span>
  </div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener external nofollow noreferrer" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/pisces/" rel="noopener external nofollow noreferrer" target="_blank">NexT.Pisces</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.24/fancybox/fancybox.umd.js" integrity="sha256-oyhjPiYRWGXaAt+ny/mTMWOnN1GBoZDUQnzzgC7FRI4=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>


  <script class="next-config" data-name="mermaid" type="application/json">{"enable":true,"theme":{"light":"default","dark":"dark"},"js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.5.0/mermaid.min.js","integrity":"sha256-K7oJiQlDulzl24ZUFOywuYme1JqBBvQzK6m8qHjt9Gk="}}</script>
  <script type="module" src="/js/zenuml-definition-074a43fa.js"></script>
  <script type="module" src="/js/mermaid-zenuml.esm.min.mjs"></script>
  <script src="/js/third-party/tags/mermaid.js"></script>


  <script src="/js/third-party/fancybox.js"></script>



  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>



</body>
</html>
